Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with t1 as
- (select *,
- SUM(price * quantity) Total,
- row_number () OVER(partition by sale_date
- ORDER BY SUM(price*Quantity) desc) as rn
- FROM sales_data
- GROUP BY product_id, price, quantity, sale_date)
- select Sale_date, product_id, Total
- from t1
- WHERE rn = 1
- ORDER BY Sale_date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement