Advertisement
rajeshinternshala

Untitled

Oct 14th, 2023
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.34 KB | None | 0 0
  1. SELECT prd.name AS name, prd.price AS price,SUM(pord.quantity) AS quantity,SUM(pord.quantity * prd.price) AS total_price
  2. FROM product prd INNER JOIN product_orders pord ON prd.id = pord.product_id INNER JOIN ORDER ord ON pord.order_id = ord.id
  3. WHERE
  4. ord.STATUS = 'Completed'
  5. GROUP BY
  6. prd.name, prd.price
  7. ORDER BY
  8. quantity DESC, total_price DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement