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

Home -> Community -> Usenet -> c.d.o.tools -> Query Help Needed

Query Help Needed

From: GZ <gregz_at_yahoo.com>
Date: Sat, 17 Feb 2001 14:13:09 GMT
Message-ID: <3A8E8A62.79D1129A@yahoo.com>

I would like to know how I can implement a if/then type logic when selecting from two tables in sub query?

I want the outer query to:

  1. take departments from table A
  2. if the department exists in table A, do not take that same department from table B.
  3. take any department from table B that does not exist in table A.

1st table in sub query brings up departments that have more than zero persons in it.

2nd table in subquery brings up departments from another table and manufactures a zero for # of people.

SELECT deptno, num_people
FROM
(SELECT deptno, num_people FROM tableA
UNION ALL
SELECT deptno, '000' as num_people FROM tableB)

Any help would be immensely appreciated!

GZ Received on Sat Feb 17 2001 - 08:13:09 CST

Original text of this message

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