here's a decode that should *NEVER* be put into production!  :)

-----Original Message-----
Sent: Thursday, September 12, 2002 12:18 PM
To: Multiple recipients of list ORACLE-L


Beware...nasty sql below

select decode((select deptno from dept where upper(loc) = upper('&vloc')),
<-- expression
              (select deptno from dept where loc = 'NEW YORK'),
<-- value1
              (select count(*) from emp where deptno = 10),
<-- return1
              (select deptno from dept where loc = 'DALLAS'),
<-- value2
              (select count(*) from emp where deptno = 20),
<-- return2
              (select deptno from dept where loc = 'CHICAGO'),
<-- value3
              (select count(*) from emp where deptno = 30),
<-- return3
              (select count(*) from emp where deptno not in (10,20,30))
<-- default_return
             ) emp_count
 from dual
 
 SQL> /
 Enter value for vloc: DALLAS
  EMP_COUNT
 ----------
          5
 
 SQL> /
 Enter value for vloc: Chicago
  EMP_COUNT
 ----------
          6
 
 SQL> /
 Enter value for vloc: DENVER
  EMP_COUNT
 ----------
          0
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Fink, Dan
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
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).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Mercadante, Thomas F
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
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).

Reply via email to