-
-- 解法一
-
SELECT
-
t1.teacher_no,
-
(CASE WEEK WHEN '1' THEN keshuELSE 0END ) 礼拜一,
-
(CASE WEEK WHEN '2' THEN keshuELSE 0END ) 礼拜二,
-
(CASE WEEK WHEN '3' THEN keshuELSE 0END ) 礼拜三
-
FROM
-
(
-
SELECT
-
teacher_no,
-
WEEK,
-
COUNT(1) AS keshu
-
FROM teach
-
GROUP BY teacher_no,WEEK
-
)t1
-
GROUP BY t1.teacher_no;
-
-
-
-- 解法二 就是count()函数作用
-
SELECT
-
t1.teacher_no,
-
(CASE WEEK WHEN '1' THEN keshuELSE 0END ) 礼拜一,
-
(CASE WEEK WHEN '2' THEN keshuELSE 0END ) 礼拜二,
-
(CASE WEEK WHEN '3' THEN keshuELSE 0END ) 礼拜三
-
FROM
-
(
-
SELECT
-
t.teacher_no,
-
t.WEEK,
-
COUNT(t.keshu) AS keshu
-
FROM
-
(
-
SELECT
-
teacher_no,
-
WEEK,
-
'1' keshu
-
FROM teach)t
-
GROUP BY teacher_no,WEEK
-
)t1
-
GROUP BY t1.teacher_no
-
;
站在用户的角度思考问题,与客户深入沟通,找到启东网站设计与启东网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站设计、网站建设、企业官网、英文网站、手机端网站、网站推广、域名注册、网站空间、企业邮箱。业务覆盖启东地区。
标题名称:(一)、根据teacher_no统计星期的上课数
文章起源:
http://mswzjz.cn/article/pdhoog.html