[문제]
여기서 id 별로 partition을 주어 누적합을 구해보자
SELECT id,
Name,
Kg,
Line,
SUM(kg) OVER (ORDER BY Line PARTITION BY id) AS Cumsum
FROM Elevator
select el.id
, el.name
, el.kg
, el.Line
, SUM(e2.kg) AS CumSum
from Elevator e1
Inner Join Elevator e2
on el.id = e2.id
and el.Line >= e2.Line -- 이곳에다 partition을 주는 것임
GROUP BY el.id,el.name,el.kg,el.Line
SELECT e1.id
, el.name
, el.kg
, el.Line
, (select sum(e2.kg)
from elevator e2
where el.id = e2.id
and el.Line >= e2.Line) AS CumSum
FROM Elevator e1