ID Value 2 100 5 250 8 150 12 200
SELECT ID, Value FROM Values ORDER BY Value DESC
ID Value Total 5 250 250 12 200 400 (250 + 200) 8 150 550 (400 + 150) 2 100 650 (550 + 100)
SELECT A.ID, A.Value (SELECT SUM(Value) FROM Values B WHERE B.Id <= A.Id) AS Total FROM Values A ORDER BY A.Value DESC
select a1.id,a1.value, sum(a2.value) from Values a1, Values a2 where a1.id < a2.id or (a1.id = a2.id and a1.value=a2.value) group by a1.id,a1.value order by a1.id desc ,a1.value desc
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)