If my query returns the following result:
NAME1 10
NAME2 20
NAME3 15
NAME4 5
NAME5 25
is there any way (without using cursors) to add a column that adds the numbers so that I get the following result:
NAME1 10 10
NAME2 20 30
NAME3 15 45
NAME4 5 50
NAME5 25 75
? thanks in advanceyes, with a theta joinselect t1.name
, t1.num
, sum(t2.num) as accum
from yourtable as t1
inner
join yourtable as t2
on t1.name >= t2.name
group
by t1.name
, t1.num
order by t1.namenotice the inequality in the join condition
No comments:
Post a Comment