Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Totals

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Can anyone tell me how to create a running total in a view.

Example
Item Qty Running Total
Part1 20 20
Part2 30 50
part3 10 60

Thank You
 
I belie a good idea is you to add an index(as RecordID) at the first:

RecordID Item Qty Running Total
1 Part1 20 20
2 Part2 30 50
3 Part3 10 60

at the second:
----
select
Item, Total,
(
select sum(qty) from YourTable t
where RecordID <= YourTable.RecordID
)RunningTotal
from YourTable
order by RecordID
---- John Fill
ivfmd@mail.md
 
SELECT Item, Qty, (select sum(qty) from yourtable T
where T.Item <= yourtable.Item) 'Running Total'
FROM yourtable
ORDER BY Item
Andel
andelbarroga@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top