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
 General SQL Server Forums
 New to SQL Server Programming
 joining 4 tables

Author  Topic 

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2008-01-09 : 21:20:29
Hi guys please help!

Given the following tables:
table 1
1ClientNo 1BirthDate 1FirstName 1MiddleName 1LastName
100 08/12/1982 Tom Merry Hanks
101 08/13/1982 May Hero Thompson
102 08/14/1982 Drew Berry More
103 08/15/1985 Minerva Lee Potter
table 2
2ClientNo 2AccountNo
100 18010515
101 18010450
102 18010220
103 18010220

table 3 3AccountNo 3Name 3Balance
18010515 Tom Merry Hanks 100
18010450 May Hero Thompson 200
18010220 Drew and Minierva 200
18010220 Drew and Minierva 200
table 4 4AccountNo 4DatePosted
18010515 10/11/2005
18010450
What query can I build so that I can get this result?

ClientID AccountNo Name Balance DatePosted
100 18010515 Tom Merry Hanks 100 10/11/2005
101 18010450 May Hero Thompson 200
102 18010220 Drew and Minierva 200


Thanks!

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-01-09 : 21:31:28


Select DISTINCT min(ClientNo) as ClientID, d.AccountNo, c.Name, c.Balance,d.DatePosted
FROM [Table1] a inner join [Table2] b on a.ClientNo = b.ClientNo
inner join [Table3] c on b.AccountNo = c.AccountNo
inner join [Table4] d on c.AccountNo = d.AccountNo


Might get you started...



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

eem_2055
Yak Posting Veteran

69 Posts

Posted - 2008-01-09 : 22:45:12
thanks a lot bro..
Go to Top of Page
   

- Advertisement -