Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT prd.name AS name, prd.price AS price,SUM(pord.quantity) AS quantity,SUM(pord.quantity * prd.price) AS total_price
- FROM product prd INNER JOIN product_orders pord ON prd.id = pord.product_id INNER JOIN ORDER ord ON pord.order_id = ord.id
- WHERE
- ord.STATUS = 'Completed'
- GROUP BY
- prd.name, prd.price
- ORDER BY
- quantity DESC, total_price DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement