Andrea Oracle wrote: > > Hi, I got a SQL question (9i on Red Hat), commands > shown below. The first sql returns 3 rows with value > 1, so trim(client_company) = '', how come the 2nd sql > doesn't return anything?? > > SQL> select decode(trim(client_company), '', 1, ' ', > 2, null, 3, 4) from cli_clients where > cli_id in (257, 396, 727); > > DECODE(TRIM(CLIENT_COMPANY),'',1,'',2,NULL,3,4) > ----------------------------------------------- > 1 > 1 > 1 > > 3 rows selected. > > SQL> select count(*) from cli_clients where > trim(client_company) = '' and cli_id in (257, > 396, 727); > > COUNT(*) > --------- > 0 > > 1 row selected. >
Because NULLs (and '' is a NULL string) can be DECODEdbut are never equal to anything. -- Regards, Stephane Faroult Oriole Software -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Stephane Faroult INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
