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