Advertisement
rajeshinternshala

Untitled

Oct 14th, 2023
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.35 KB | None | 0 0
  1. Select pds.name AS name, pds.price AS price,SUM(pods.quantity) AS quantity,SUM(pods.quantity * pds.price) AS total_price
  2. from products pds inner join products_odsers pods ON pds.id = pods.product_id inner join odsers ods ON pods.odser_id = ods.id
  3. where
  4. ods.status = 'Completed'
  5. group by
  6. pds.name, pds.price
  7. odser by
  8. quantity DESC, total_price DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement