Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with x as (select user_id,
- created_at::date date,
- count(id) as txs
- from transactions t
- where --user_id = 17419 and
- type like '%sell_subscription%'
- and created_at::date in ('2024-11-01','2024-10-01')
- group by 1,2
- order by 2,1)
- select x.user_id,
- concat(u.first_name, ' ', u.last_name) as user_name,
- MAX(txs)filter (where date = '2024-10-01') as _2024_10_01,
- MAX(txs)filter (where date = '2024-11-01') as _2024_11_01
- from x
- join users u on x.user_id = u.id
- group by 1,2
- having MAX(txs)filter (where date = '2024-10-01') > 50
- order by 3 desc
Advertisement
Add Comment
Please, Sign In to add comment