从MySQL SELECT中删除列

时间:2012-11-15 05:49:18

标签: mysql select

我根据客户数量从数据库中提取名单:

SELECT Name, count(CustName) FROM orders GROUP BY Name;

它返回:

+--------+-----------------+
| Name   | count(CustName) |
+--------+-----------------+
| Abel   |               3 |
| Jones  |               2 |
| Murphy |               1 |
| Zenith |               1 |
+--------+-----------------+

我现在如何,只列出有计数的姓名(CustNames)> = 2?我不想看到count(CustName)列。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:3)

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