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.
| Author |
Topic |
|
deeptish
Starting Member
1 Post |
Posted - 2012-06-05 : 07:47:39
|
| Can somebody help me by writing a query that retrieve the unique combination of records (value1,value2) those are present in query 1 but not in query 2. NOTE : table 2 is much bigger than table 1 and both the table may have duplicate values Query 1 Select value1,value2 from <table 1> group by value1,value2 order by value1,value2 Query 2Select value1,value2 from <table 2>group by value1,value2 order by value1,value2 ThanksDeeptish |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-05 : 09:32:11
|
| Select distinct t1.value1,t1.value2from [table 1] t1left join [table 2] t2on t1.value1 = t2.value1and t1.value2 = t2.value2where t2.value1 is null==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-05 : 10:24:33
|
| [code]Select value1,value2 from <table 1> t1WHERE NOT EXISTS (SELECT 1 FROM <table 2> WHERE value1 = t1.value1 AND value2 = t1.value2 )[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|