andrey_vetrov

part_1_tema_2_lesson_17_task_6

Apr 23rd, 2022
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. WITH
  2. pz AS (SELECT *,
  3. DATE_TRUNC('month', created_at)::date AS month_of_costs,
  4. SUM(costs) OVER (
  5. ORDER BY DATE_TRUNC('month', created_at)) AS total_amt
  6. FROM tools_shop.costs)
  7.  
  8. SELECT DISTINCT month_of_costs, total_amt
  9. FROM pz
  10. WHERE EXTRACT(
  11. YEAR FROM month_of_costs) IN (2017,2018)
  12.  
  13.  
Advertisement
Add Comment
Please, Sign In to add comment