Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I write a query to get the first_name and last_name of customers having orders containing more than 2 items?

These are the tables i am supposed to extract the data from

How do I write a query to get the first_name and last_name of customers having orders containing more than 2 items?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This should work:

SELECT 
s.first_name, s.last_name
 FROM sales_order s 
 JOIN sales_order_item so 
 ON so.fk_sales_order=s.id_sales_order
GROUP BY so.fk_sales_order
HAVING COUNT(*)>2
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading