Mysql - Counting NULL总是返回0?

时间:2013-09-05 12:13:14

标签: mysql

我试图得到这个结果:

NULL    350
google  98
yahoo   5
bing    4

使用此查询:

SELECT engine, COUNT(engine) AS count
FROM visits
GROUP BY engine
ORDER BY count DESC

但它返回:

google  98
yahoo   5
bing    4
NULL    0

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

改为使用COUNT(1)

SELECT engine, COUNT(1) AS count
FROM visits
GROUP BY engine
ORDER BY count DESC;