Untitled
Anonymous
plain_text
04/06/2023 5:45 AM
448 B
22
Indexable
WITH
gr_mon AS (SELECT CAST(DATE_TRUNC('month', created_at) AS date) AS month,
SUM(costs) AS month_cost
FROM tools_shop.costs
GROUP BY month)
SELECT *,
month_cost - LAG(month_cost, 1, month_cost) OVER (ORDER BY month_cost) AS costs_from_previous
FROM gr_monEditor is loading...