Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with t1 as (
- select 'window' as window, charge_at::date, sum(gross_amount) as rev from public.monthly_charges
- where charge_at >= current_date - 30
- and charge_at < current_date
- group by 1,2
- order by 2 desc
- ), t2 as (
- select
- *,
- avg(rev) over (partition by window) as avg_rev
- from t1
- )
- select * from t2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement