Re: Query help needed - correction

From: The Ghost <The_at_Ghost.com>
Date: Sat, 17 Feb 2001 16:58:02 GMT
Message-ID: <u4yj6.159877$KP3.41953024_at_news3.rdc1.on.home.com>


select xxx from table1
minus select xxx from table2
union
select xxx from table2
minus
select xxx from table1

"GZ" <gregz_at_yahoo.com> wrote in message news:3A8E89AE.7C8080B3_at_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 - 17:58:02 CET

Original text of this message