Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. with t1 as
  2. (select *,
  3. SUM(price * quantity) Total,
  4. row_number () OVER(partition by sale_date
  5. ORDER BY SUM(price*Quantity) desc) as rn
  6. FROM sales_data
  7. GROUP BY product_id, price, quantity, sale_date)
  8.  
  9.  
  10. select Sale_date, product_id, Total
  11. from t1
  12. WHERE rn = 1
  13. ORDER BY Sale_date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement