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)
 query

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2009-03-25 : 10:52:56
[code]
I need a query which should pull the output

Table:CustA


CID CName
------ ------
1 Sam
2 Pat
3 Mat
4 Jef


Table:CustB


CID Comp
------ ----
1 Van
2 Man
3 Mso


Table:CustC


CID Age
------ ----
1 30
2 25



Output




CID CName Comp Age
---- ----- ---- ---
1 Sam Van 30
2 Pat Man 25
3 Mat Mso null
4 Jef null null
[/code]

heavymind
Posting Yak Master

115 Posts

Posted - 2009-03-25 : 10:55:04
select cn.cid, cname, comp, age
from CustA cn
left outer join CustB b on cn.cid = b.cid
left outer join CustC con cn.cid = c.cid

Thanks, Vadym
MCITP DBA 2005/2008
Chief DBA at http://www.db-staff.com
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2009-03-25 : 12:01:40
Thanks!!
I need to extend the query with filter conditions for the status

select cn.cid, cname, comp, age
from CustA cn
left outer join CustB b on cn.cid = b.cid
left outer join CustC con cn.cid = c.cid
Where (cn.Vstatus=5 and cn.Dstatus=0,cn.Tstatus in (5,0))
and (b.Vstatus=5 and b.Dstatus=0,b.Tstatus in (5,0))


correct the where conditions
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-25 : 13:11:18
quote:
Originally posted by sqlfresher2k7

Thanks!!
I need to extend the query with filter conditions for the status

select cn.cid, cname, comp, age
from CustA cn
left outer join CustB b on cn.cid = b.cid
left outer join CustC con cn.cid = c.cid
Where (cn.Vstatus=5 and cn.Dstatus=0,cn.Tstatus in (5,0))
and (b.Vstatus=5 and b.Dstatus=0,b.Tstatus in (5,0))


correct the where conditions



are you expecting spoon feeded answers? your question is straight forward. even after getting a pointer cant you extend it based on your reuirement? look in sql server books online and see how you write where condition rather than looking for spoon feeded answers.you wont gain anything by doing this.
Go to Top of Page
   

- Advertisement -