Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Union question

Author  Topic 

theboyholty
Posting Yak Master

226 Posts

Posted - 2009-08-11 : 11:09:45
Is there a Union operator or something similar which would just show me the difference between two result sets?

For example.

select exampletext,'q1' as source from wherever
union
select exampletext,'q2' as source from wherever
order by source,exampletext

produces:

aaa,q1
bbb,q1
ccc,q1
aaa,q2
bbb,q2

The difference being the 'ccc' that query 1 produced. I want the result of my query to ONLY show the ccc,q1


---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk The official unofficial website of Bury Football Club

X002548
Not Just a Number

15586 Posts

Posted - 2009-08-11 : 11:13:41
GROUP BY Col
HAVING COUNT(*) = 1

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2009-08-11 : 20:00:12
Does this fit your needs?

select exampletext,'q1' as source from wherever

EXCEPT

select exampletext,'q2' as source from wherever
order by source,exampletext


=======================================
Men build too many walls and not enough bridges. -Isaac Newton, philosopher and mathematician (1642-1727)
Go to Top of Page
   

- Advertisement -