Untitled
unknown
plain_text
3 years ago
340 B
17
Indexable
WITH p AS
(SELECT DATE_TRUNC('month', created_at::date)::date AS month,
DATE_TRUNC('year', created_at::date) AS year,
SUM(costs) OVER (ORDER BY DATE_TRUNC('month', created_at::date)) AS total
FROM tools_shop.costs
)
SELECT month,
total
FROM p
WHERE year IN ('2017-01-01', '2018-01-01');Editor is loading...