select courseId, stuId,
sum(case when state=1 then 1) normal,
sum(case when state=2 then 1) dayoff
from table group by courseId, stuId
sum(case when state=1 then 1) normal,
sum(case when state=2 then 1) dayoff
from table group by courseId, stuId
显示语法错误喔
[SQL]SELECT
courseId,
stuId,
sum(CASE WHEN state = 1 THEN 1) normal,
sum(CASE WHEN state = 2 THEN 1) dayoff
FROM
kaoqin
GROUP BY
courseId,
stuId[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') normal,
sum(CASE WHEN state = 2 THEN 1) dayoff
FROM
kaoqin
GROUP BY
co' at line 4
貌似是这里语法错误
courseId,
stuId,
sum(state=1) normal,
sum(state=2) dayoff
FROM
kaoqin
GROUP BY
courseId,
stuId
我直接这样写貌似就可以了,不过多谢#1帮我解决的