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 |
|
Yawriats
Starting Member
2 Posts |
Posted - 2012-03-05 : 08:28:46
|
| Hi!I have one table with dates (say 20th - 30th January), and other table with transactions and dates:Date | Transaction2012-01-20 300$2012-01-22 -100$2012-01-25 500$...I want to display something like this:Date | Total money (on each day)2012-01-20 300$2012-01-21 300$2012-01-22 200$2012-01-23 200$2012-01-24 200$2012-01-25 700$...So, I want to sum every transaction up to each row date. Can't figure this one out... |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-05 : 08:40:07
|
[code]select t1.date, (select sum(transaction) from table2 t2 where t2.date <= t1.date)from table1 t1[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Yawriats
Starting Member
2 Posts |
Posted - 2012-03-05 : 08:52:21
|
| Thank you! |
 |
|
|
|
|
|