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 |
|
uj0e
Starting Member
2 Posts |
Posted - 2007-10-28 : 10:15:45
|
| help me please..I have a problem getting some rows on sql.the problem is, i've got an employee and money table like thisemployee tableEmplid| name | moneyleft|AFE Alfred 50Money TableEmplid| getmoney|AFE 10AFE 15I want to get rows like thisEmplid| name | moneyleft | getmoney| balance|AFE Alfred 50 10 40AFE Alfred 40 15 25The problem is, I must calculate moneyleft field from employee table on the next rows without changed the first value moneyleft field on employee table.Major problem is software that i used not support declare syntax.So I must use pure select syntax..Help Meeee.... |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2007-10-28 : 10:24:28
|
| Is there a date field or another field you can use to identify the order? It might help in setting this up..it can be done I am sure how you need it.What software do you use that supports Select but not variable declaration? |
 |
|
|
Koji Matsumura
Posting Yak Master
141 Posts |
Posted - 2007-10-28 : 21:48:13
|
| SELECT A.Emplid, A.name, A.moneyleft, B.getmoney,A.moneyLeft - (SELECT SUM(Z.getmoney) FROM MoneyTable Z WHERE (Include records less than or equal to B using order of Money Table)) AS balanceFROM EmployeeTable AINNER JOIN MoneyTable B On B.Emplid = A.EmplidORDER BY (order of Money Table here) |
 |
|
|
uj0e
Starting Member
2 Posts |
Posted - 2007-11-03 : 11:17:06
|
| Thank's A lot guys.. |
 |
|
|
|
|
|