|
Home > Archive > MS SQL Server > July 2005 > UNION and minusing 3rd result set
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
UNION and minusing 3rd result set
|
|
| Khurram Shahzad 2005-07-28, 7:23 am |
| Dear all,
I want to do a UNION of 2 queries and Minusing the result set of 3rd query.
I know it is workable in Oracle using MINUS clause.
select * from table a
where ..
UNION
select * from table b
where ..
MINUSING
select * from table c
where ..
Kind regards
Khurram Shahzad
| |
| Tibor Karaszi 2005-07-28, 7:23 am |
| Union the first two and take that result and do a NOT EXISTS:
SELECT col1, col2, ...
FROM
(
select * from table a
where ..
UNION
select * from table b
where ..
) AS d
WHERE NOT EXISTS
(
select * from table c
where c.id = d.id
)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www. solidqualitylearning
.com/
Blog: http:// solidqualitylearning
.com/blogs/tibor/
"Khurram Shahzad" <Khurram.Shahzad@360training.com> wrote in message
news:efadVc1kFHA.1440@TK2MSFTNGP14.phx.gbl...
> Dear all,
>
> I want to do a UNION of 2 queries and Minusing the result set of 3rd query. I know it is workable
> in Oracle using MINUS clause.
>
> select * from table a
> where ..
> UNION
> select * from table b
> where ..
> MINUSING
> select * from table c
> where ..
>
> Kind regards
> Khurram Shahzad
>
|
|
|
|
|