标签:sub from when select stat bsp cas ota 汇总
SELECT
count(0) as totalNum,
sum(CASE WHEN learn_status = ‘1‘ AND subject_type = ‘3‘ AND STATUS = ‘1‘ THEN 1 ELSE 0 END) AS km1,
sum(CASE WHEN learn_status = ‘1‘ AND subject_type = ‘4‘ AND STATUS = ‘1‘ THEN 1 ELSE 0 END) AS km2,
sum(CASE WHEN learn_status = ‘1‘ AND subject_type = ‘5‘ AND STATUS = ‘1‘ THEN 1 ELSE 0 END) AS km3,
sum(CASE WHEN learn_status = ‘1‘ AND subject_type = ‘6‘ AND STATUS = ‘1‘ THEN 1 ELSE 0 END) AS km4
FROM
sm_student t
WHERE 1 = 1 AND school_id =1
按照学校找到科目3,4,5,6汇总的人数
标签:sub from when select stat bsp cas ota 汇总
原文地址:http://www.cnblogs.com/mqy1/p/6723035.html