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 |
kadiyalabindu
Starting Member
7 Posts |
Posted - 2005-09-15 : 04:31:43
|
Hi All,I am getting the following output with this query :SELECT day, sales, sales+IIf(IsNull((SELECT SUM(sales) FROM sales b WHERE b.day < a.day)),0,(SELECT SUM(sales) FROM sales b WHERE b.day < a.day)) AS RunningTotalFROM sales AS a ORDER BY day;This query is working perfectly with the different days. Day Sales output1 60 602 40 1003 50 1504 60 210But the days are repeating for more than once it is giving the wrong output i Have even used Group by Clause but still i am getting the wrong output.This shld work with these data:Day Sales 1 60 1 40 2 50 2 60 My expected output is :Day Runningtot1 1002 110Can anyone sort out with this problem.Thanks in advance..regards |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-15 : 04:42:52
|
Select Day, Sum(Sales) from yourTable group by DayMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|