toropyga

sql_01-07

May 14th, 2022 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with tbl as (
  2.     select distinct date_trunc('month', event_time)::date as month
  3.         , count(event_id) over(partition by date_trunc('month', event_time)) as events
  4.     from tools_shop.events e
  5.     right join tools_shop.orders o on o.user_id=e.user_id
  6.     where event_name='view_item'
  7. )
  8. select month , events::numeric, sum(events) over(order by month)
  9. from tbl
Add Comment
Please, Sign In to add comment