SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need a SQL Statement to Arrive result
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

aravindt77
Posting Yak Master

India
120 Posts

Posted - 07/24/2007 :  04:14:53  Show Profile  Visit aravindt77's Homepage  Reply with Quote
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 data

create 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 btn

The result will be like this

pg kn
------
0 41
------
1 61
------


Plz do the needful

Thankz & Regards

Aravind


khtan
In (Som, Ni, Yak)

Singapore
17626 Posts

Posted - 07/24/2007 :  04:48:28  Show Profile  Reply with Quote
SELECT	a.pg, a.kn
FROM	btall a left JOIN bt b
	ON	a.pg	= b.pg
	AND	a.kn	= b.kn
WHERE	b.pg	IS NULL



KH
Time is always against us

Go to Top of Page

aravindt77
Posting Yak Master

India
120 Posts

Posted - 07/24/2007 :  08:33:07  Show Profile  Visit aravindt77's Homepage  Reply with Quote
Thank you very much
[/quote]
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000