MYSQL计算非空行

时间:2015-09-26 05:09:28

标签: mysql

我只需要计算那些非空的行。谢谢。

SELECT component,count(comp_details) FROM table GROUP BY component

2 个答案:

答案 0 :(得分:2)

虽然您希望有条件地计算,但您的查询没有任何WHERE部分

SELECT component,count(comp_details) 
FROM table 
WHERE IFNULL(component, '') != ''
GROUP BY component

答案 1 :(得分:0)

尝试这样:根据要求添加where子句。

SELECT component,count(comp_details) FROM table where comp_details is not null and comp_details != "" GROUP BY component
相关问题