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 |
aravindt77
Posting Yak Master
120 Posts |
Posted - 2007-07-24 : 04:14:53
|
Hi All,I need a SQL Statement to get the result in the criteria which i need. Below I m providing the Table and valid datacreate table bt (pg int , kn int ,st int)create table btall (pg int , kn int ,st int)insert into bt values(0,48,2)insert into bt values(0,64,2)insert into bt values(0,80,2)insert into btall values(0,48,3)insert into btall values(0,48,4)insert into btall values(0,64,3)insert into btall values(0,64,4)insert into btall values(0,80,3)insert into btall values(0,80,4)insert into btall values(0,41,3)insert into btall values(1,61,3)I need the result in which need to arrive data from btnall where 1. pg only in btnall but not in btn 2. pg & kn in btnall but not in btnThe result will be like thispg kn------0 41------1 61------Plz do the needfulThankz & RegardsAravind |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-24 : 04:48:28
|
[code]SELECT a.pg, a.knFROM btall a left JOIN bt b ON a.pg = b.pg AND a.kn = b.knWHERE b.pg IS NULL[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
aravindt77
Posting Yak Master
120 Posts |
Posted - 2007-07-24 : 08:33:07
|
Thank you very much[/quote] |
|
|
|
|
|
|
|