Advertisement
AlexanderDM

shiz

Nov 21st, 2022
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH temple AS (SELECT DATE_TRUNC('month', created_at::date),
  2.                 COUNT(user_id) OVER (PARTITION BY DATE_TRUNC('month', created_at::date))
  3. FROM tools_shop.users),
  4.  
  5. shrine AS (SELECT DISTINCT(date_trunc)::date AS month, count
  6.            FROM temple),
  7.  
  8. pagoda AS (SELECT month,
  9.                SUM(count) OVER (ORDER BY month) AS overall
  10.                FROM shrine)
  11.  
  12. SELECT month, overall
  13. FROM pagoda
  14. ORDER BY month DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement