BDV
BDV

Reputation: 21

Remove column from MySQL SELECT

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

Answers (1)

Muhammad Raheel
Muhammad Raheel

Reputation: 19882

SELECT 
      Name
FROM orders 
GROUP BY Name
HAVING count(CustName) >= 2;

Upvotes: 3

Related Questions