Untitled

 avatar
unknown
plain_text
3 years ago
194 B
83
Indexable
WITH mc AS (SELECT CAST(DATE_TRUNC('month', created_at) as date) as dt, sum(costs) as sc
from tools_shop.costs
group by dt)

SELECT *, sc - LAG(sc, 1, NULL) OVER(order by dt) as sc2
FROM mc
Editor is loading...