Reputation: 21
I am pulling a list of names from the Database based on number of customers:
SELECT Name, count(CustName) FROM orders GROUP BY Name;
It returns:
+--------+-----------------+
| Name | count(CustName) |
+--------+-----------------+
| Abel | 3 |
| Jones | 2 |
| Murphy | 1 |
| Zenith | 1 |
+--------+-----------------+
How do I now, ONLY list Names that have count(CustNames) >= 2? I do not want to see the count(CustName) column.
Any help is greatly appreciated.
Upvotes: 0
Views: 147
Reputation: 19882
SELECT
Name
FROM orders
GROUP BY Name
HAVING count(CustName) >= 2;
Upvotes: 3