Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with t1 as
- (SELECT sale_date, product_id,
- SUM(price * Quantity) as Total,
- dense_rank() OVER(PARTITION BY sale_date
- ORDER BY SUM(price * quantity) DESC) as dr
- FROM sales_data
- GROUP BY 1, 2)
- SELECT sale_date, product_id, Total
- from t1
- WHERE dr = 1
- ORDER BY sale_date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement