我有一个专栏“小时” 我有一个列“ kind”(可以是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 告诉我,我有一个错误... 什么是错误! ?
请参阅这个堆栈溢出主题: MySQL SUM IF field b = field a
我无法回答这个问题。