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.

 All Forums
 Other Forums
 MS Access
 Help me in upgrading my Running Total Query

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 RunningTotal
FROM sales AS a
ORDER BY day;

This query is working perfectly with the different days.

Day Sales output
1 60 60
2 40 100
3 50 150
4 60 210

But 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 Runningtot
1 100
2 110

Can 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 Day

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -