-
Junior Member
Query
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??????
-
Expert Member
-
Contributing Member
Re: Query
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;
-
Junior Member
Re: Query
Thanks a lot Barbie and varmakub; the query is showing the correct information right now.
-
Re: Query
simply use decode as suggested.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules