Advertisement
AliaksandrLet

Задача 10

Oct 23rd, 2022 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH cte AS (
  2.     SELECT
  3.         DATE_TRUNC('year', paid_at)::date AS year,
  4.         SUM(total_amt) AS sum
  5.     FROM
  6.         tools_shop.orders
  7.     GROUP BY
  8.         year
  9. )
  10. SELECT
  11.     year,
  12.     sum,
  13.     LEAD(sum, 1, sum) OVER (ORDER BY year) - sum AS dif
  14. FROM
  15.     cte
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement