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 -> Re: [Q] Conditions in the column expression?

Re: [Q] Conditions in the column expression?

From: mcstock <mcstockspamplug_at_spamdamenquery.com>
Date: Wed, 26 Nov 2003 07:59:43 -0500
Message-ID: <q6Odnbj8NpVFPlmiRVn-vw@comcast.com>


you can't do predicate-style expressions in the column list, but you can use functions and expressions

look into

CASE
DECODE
SIGN
NVL See the chapter 'Expressions, Conditions, and Queries' in the 8i SQL Reference manual, or the Expressions in the 9i SQL Reference Manual

"Ano Nymus" <ano.nymus_at_none.com> wrote in message news:3fc46dad_4_at_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 - 06:59:43 CST

Original text of this message

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