Home > Software engineering >  How do I write a query to get the first_name and last_name of customers having orders containing mor
How do I write a query to get the first_name and last_name of customers having orders containing mor

Time:07-10

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?

CodePudding user response:

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
  • Related