Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Select pds.name AS name, pds.price AS price,SUM(pods.quantity) AS quantity,SUM(pods.quantity * pds.price) AS total_price
- from products pds inner join products_odsers pods ON pds.id = pods.product_id inner join odsers ods ON pods.odser_id = ods.id
- where
- ods.status = 'Completed'
- group by
- pds.name, pds.price
- odser by
- quantity DESC, total_price DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement