Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> [Q] Conditions in the column expression?
I have a table t with columns n and m of type VARCHAR. I
want to retrieve the entire n column, but I want the entries
to be ordered such that those entries where m is null come
first. As pseudo-code:
SELECT n, (IF m IS NULL THEN 0 ELSE 1) AS c
FROM t
ORDER BY c, n;
Moreover, I want to retrieve all those entries of n whose length is greater than 5, but I want NULL values for all those entries whose length is less or equal than 5. In pseudo-code:
SELECT (IF LENGTH(m) <= 5 THEN NULL ELSE m) FROM t;
How do I do this in Oracle? Received on Wed Nov 26 2003 - 03:09:05 CST
![]() |
![]() |