Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> [Q] Conditions in the column expression?

[Q] Conditions in the column expression?

From: Ano Nymus <ano.nymus_at_none.com>
Date: Wed, 26 Nov 2003 10:09:05 +0100
Message-ID: <3fc46dad_4@newsgate.singtel.com.hk>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US