一些简单sql
Posted 无敌的小小哒
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一些简单sql相关的知识,希望对你有一定的参考价值。
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汇总的人数
以上是关于一些简单sql的主要内容,如果未能解决你的问题,请参考以下文章