Hi everyone, I'm making a query to one table and I need to get different information from one numeric field but there is not data in all records... how can I get a zero in the result?????? :confused:
Printable View
Hi everyone, I'm making a query to one table and I need to get different information from one numeric field but there is not data in all records... how can I get a zero in the result?????? :confused:
use decode then.
Decode function has the functionality of an IF-THEN-ELSE statement.
The syntax for the decode function is:
decode( expression , search , result [, search , result]... [, default] )
expression is the value to compare.
search is the value that is compared against expression.
result is the value returned, if expression is equal to search.
default is optional. If no matches are found, the decode will return default. If default is omitted, then the decode statement will return null (if no matches are found).
For Example:
You could use the decode function in an SQL statement as follows:
SELECT supplier_name,
decode(supplier_id, 10000, 'DELL',
10001, 'INFOSYS',
10002, 'WIPRO',
'Gateway') result
FROM suppliers;
Thanks a lot Barbie and varmakub; the query is showing the correct information right now. :D
simply use decode as suggested.