-
-- 解法一
-
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()函數(shù)作用
-
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
-
;
站在用戶的角度思考問題,與客戶深入溝通,找到啟東網(wǎng)站設(shè)計與啟東網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋啟東地區(qū)。
本文名稱:(一)、根據(jù)teacher_no統(tǒng)計星期的上課數(shù)
網(wǎng)址分享:
http://weahome.cn/article/pdhoog.html