我有一列“小时”我有一列“种类”(可以是 1,2 或 3)
我想做类似的事情:
SELECT count(id), SUM(hour) as totHour, SUM( IF ( kind = 1, 1, 0 ) ) as countKindOne
或者
SELECT count(id), SUM(hour) as totHour, COUNT( IF ( kind = 1 ) ) as countKindOne
但是mysql告诉我我有一个错误......错误是什么!?
请参阅此 stackoverflow 主题:MySQL SUM IF field b = field a
..我无法回复这个...