Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. select city_category, user_id, avg(purchase) as average_purchase, dense_rank() over(partition by city_category order by user_id desc)
  2. from blackfriday b
  3. group by b.user_id, city_category
  4. having avg(purchase) > ( select avg(purchase)
  5. from blackfriday a
  6. where a.city_category = b.city_category
  7. group by city_category)
  8. order by b.city_category, user_id
  9. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement