Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> newbie's question about 'decode'
Hi, I have Oracle 7.2 loaded on my PC for a course I'm taking, and I have questions about using DECODE within a select query used to generate reports. I get the concept that DECODE acts as a conditional function (i.e., an if-then-else statement) that can be used to format column results for a report. If a column contains a null value, you can use DECODE to change the values to say 'No Value' for, say, col_test, in the report. And that works for me. But I have a situation where I have to display different output for col_test depending on what's contained in, say, col_type (not a primary key, by the way). In other words, for a table, all the values in col_test may be null but if the value in col_type is 'A', the report should state 'No Value' for the value in col_test or display a 0 (zero) for a col-type of 'B'. Can you nest DECODE's within a select statement as a way to test for the values in col_type (i.e., decode(col_test, decode (col_type, NULL....)))? I've had unpredictable results so far with all the results in col_test changed and even results in col_type changed. Any insights would be greatly appreciated, and thanks.
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
Received on Sun Jun 18 2000 - 00:00:00 CDT
![]() |
![]() |