cancel
Showing results for 
Search instead for 
Did you mean: 

SQL-code running total

Former Member
0 Kudos

Good day.

I have used the MSSQL via MS.Excel to extract data from SQL server, i would like to know how to insert the running total next to the quantity column.

TQ.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member193399
Active Participant
0 Kudos

In excel you can write an formula for the running total. Lets say your running quantity column is D and running total column is E and your and your data row starts from row 2.. Assign the formula "=D1" in cell E1. and in E2 assign the formula "=E1+D2". Now copy E2 cell and paste it for the rest of the rows i.e. E3 ...En.

If you want this in SQL it is little complicated. You can find better answer in microsoft.public.sqlserver.programming. http://groups.google.com/group/microsoft.public.sqlserver.programming/topics?lnk=srg&hl=en.

Thanks,

RT