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 |
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-06-22 : 03:14:22
|
| Hi...probs in joining...table1 - hrEmpLoanspkeyno amount fixdeduc interest1 1000 500 1002 2000 400 1003 3000 300 1004 4000 200 1005 5000 100 100table2 - hrEmpLoanPaymentsfkeyno total_payment3 25004 2000My expected result is:pkeyno balance1 10002 20003 5004 20005 5000-Thanks-Ron-"A logician trying to explain logic to a programmer is like a cat trying to explain to a fish what it's like to get wet." |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-06-22 : 03:18:30
|
[code]SELECT l.pkeyno, amount = l.amount - ISNULL(p.total_payment, 0)FROM hrEmpLoans l LEFT JOIN hrEmpLoanPayments pON l.pkeyno = p.fkeyno[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-06-22 : 03:20:30
|
| ok thanks KH. left join is the solutionto my problem.-Ron-"A logician trying to explain logic to a programmer is like a cat trying to explain to a fish what it's like to get wet." |
 |
|
|
|
|
|