Advertisement
Guest User

should be correct

a guest
Feb 26th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. with t1 as
  2. (SELECT sale_date, product_id,
  3. SUM(price * Quantity) as Total,
  4. dense_rank() OVER(PARTITION BY sale_date
  5. ORDER BY SUM(price * quantity) DESC) as dr
  6. FROM sales_data
  7. GROUP BY 1, 2)
  8.  
  9. SELECT sale_date, product_id, Total
  10. from t1
  11. WHERE dr = 1
  12. ORDER BY sale_date
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement