99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2019-01-25 閱讀量: 766
SQL分組查詢

問題描述:

數(shù)據(jù)如下:

姓名? ?? ? 課程? ?? ???分?jǐn)?shù)

張三? ?? ? 105? ?? ?? ?97

張三? ?? ? 108? ?? ?? ?65

李四? ?? ? 105? ?? ?? ?92

李四? ?? ? 108? ?? ?? ?70

趙五? ?? ? 105? ?? ?? ? 93

趙五? ?? 108? ?? ??? 97

問題:查詢 課程105 的分?jǐn)?shù)高于 課程108 的分?jǐn)?shù)的學(xué)生姓名

數(shù)據(jù)源代碼:

CREATE TABLE SCORE (NAME VARCHAR(10), COURSE VARCHAR(3), DEGREE NUMERIC(10,1));

INSERT INTO SCORE(NAME,COURSE,DEGREE) VALUES ('ZHANGSAN','105',97);

INSERT INTO SCORE(NAME,COURSE,DEGREE) VALUES ('ZHANGSAN','108',65);

INSERT INTO SCORE(NAME,COURSE,DEGREE) VALUES ('LISI','105',92);

INSERT INTO SCORE(NAME,COURSE,DEGREE) VALUES ('LISI','108',70);

INSERT INTO SCORE(NAME,COURSE,DEGREE) VALUES ('ZHAOWU','105',93);

INSERT INTO SCORE(NAME,COURSE,DEGREE) VALUES ('ZHAOWU','108',97);

解決方法:

select t_score.name

from (

select name,sum(case when course='105' then degree else 0 end) as A,

? ? ? ? ? ? ? ? ? ? ? ? sum(case when course='108' then degree else 0 end) as B from score group by name) as t_score

where A>B;

0.0000
3
關(guān)注作者
收藏
評(píng)論(0)

發(fā)表評(píng)論

暫無數(shù)據(jù)
推薦帖子