Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Return the better of two rows based on availablity and preference - NOOB!
Total Noob questions.
I've constructed the following two SQL just for testing. The idea being I prefer the row with value '1' in better, but want row with better = 2 if so_arg in row better='1' is blank, empty or null.
SELECT so_arg
FROM (
select '1' better, NULL' so_arg
FROM dual
UNION ALL
SELECT '2' better, 'b' so_arg
FROM DUAL
ORDER BY better
)
WHERE ROWNUM = 1;
This test produced the undersired result of 'NULL'. I'm looking for
'b'.
BTW, how can I do a where on fixed values of a select from dual?
SQL> select '1' so_arg from dual where so_arg = '1'; select '1' so_arg from dual where so_arg = '1'
*
Thanks in advance for any help or information! Received on Thu Mar 02 2006 - 17:18:14 CST
![]() |
![]() |