SELECT hhid,
COUNT(kind) AS h_spray
FROM pest
WHERE kind="h"
having count(spray) =0
GROUP BY hhid;
我想看到的输出是根据其种类喷洒的农药数量,但如果品牌为0,则不应计算
答案 0 :(得分:0)
下面的代码将提供计数大于1的喷雾计数。
SELECT hhid, COUNT(kind) AS h_spray
FROM pest
WHERE kind="h"
GROUP BY hhid
having count(spray) > 0;