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 |
|
eem_2055
Yak Posting Veteran
69 Posts |
Posted - 2008-01-07 : 03:26:55
|
| Hi guys,Good day!I need your help!I want to get an accurate data.Thi is a the sample table.table 1 ------------------uniqueid acctno name balance1 0201 sam 102.002 0202 mel and geo 105.003 0202 mel and geo 105.00table 2--------------uniqueid name1 sam2 mel3 geotable 3---------------uniqueid acctno1 2012 202table 4------------acctno interestdate201 10/15/02 ***what can I do to get the following result? How can I join those tables. Hope u can help me! Thanks..uniqueid acctno name balance interestdate1 201 sam 102.00 10/15/022 202 mel and geo 105.00 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-01-07 : 03:32:01
|
| [code]Selectt1.uniqueid, t1.acctno, t1.name, t1.balance, t2.interestdatefrom Table1 t1 left join table4 t2on t1.acctno = t2.acctno[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
eem_2055
Yak Posting Veteran
69 Posts |
Posted - 2008-01-07 : 04:00:22
|
| I was wrong! :(This is the correct sample table.table 1 ------------------acctno name balance0201 sam 102.000202 mel and geo 105.000202 mel and geo 105.00table 2--------------uniqueid name1 sam2 mel3 geotable 3---------------uniqueid acctno1 2012 202table 4------------acctno interestdate201 10/15/02***what can I do to get the following result? How can I join those tables. Hope u can help me! Thanks..uniqueid acctno name balance interestdate1 201 sam 102.00 10/15/022 202 mel and geo 105.00 |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-07 : 04:35:46
|
[code]select t3.uniqueid, t3.acctno, t1.name, t1.balance, t4.interestdatefrom table3 t3 inner join table1 t1 on t3.acctno = t1.acctno and t3.uniqueid = t1.uniqueid left join table4 on t3.acctno = t4.acctno[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|