Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH cte AS (
- SELECT
- DATE_TRUNC('year', paid_at)::date AS year,
- SUM(total_amt) AS sum
- FROM
- tools_shop.orders
- GROUP BY
- year
- )
- SELECT
- year,
- sum,
- LEAD(sum, 1, sum) OVER (ORDER BY year) - sum AS dif
- FROM
- cte
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement