做網(wǎng)站、滕州網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!/>
- -- 解法一
- SELECT
- t1.teacher_no,
- (CASE WEEK WHEN '1' THEN keshu ELSE 0 END ) 禮拜一,
- (CASE WEEK WHEN '2' THEN keshu ELSE 0 END ) 禮拜二,
- (CASE WEEK WHEN '3' THEN keshu ELSE 0 END ) 禮拜三
- 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 keshu ELSE 0 END ) 禮拜一,
- (CASE WEEK WHEN '2' THEN keshu ELSE 0 END ) 禮拜二,
- (CASE WEEK WHEN '3' THEN keshu ELSE 0 END ) 禮拜三
- 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)頁名稱:(一)、根據(jù)teacher_no統(tǒng)計星期的上課數(shù)-創(chuàng)新互聯(lián)
本文地址:
http://weahome.cn/article/cojsgp.html