Reputation: 963
I am very new in SQL and i need a output like this. I have a table
Name Price
----------------
A 10
B 20
C 30
and output should be
Name Price running
--------------------------
A 10 10
B 20 30
C 30 60
Please Tell me the Query for this output.
Upvotes: 0
Views: 124
Reputation: 17194
You need this:
select t1.Name, t1.Price,
SUM(t2.Price) as running
from your_table t1 inner join your_table t2
on t1.Name >= t2.Name
group by t1.Name, t1.Price
order by t1.Name
Upvotes: 1