欢迎大家来到IT世界,在知识的湖畔探索吧!
create table student(
name varchar2(30),
gj varchar2(20),
score number(4,1)
);
insert into student (name, gj, score) values (‘李二’, ‘中国’, 90);
insert into student (name, gj, score) values (‘张无忌’, ‘美国’, 80);
insert into student (name, gj, score) values (‘周芷若’, ‘俄罗斯’, 79);
insert into student (name, gj, score) values (‘xx’, ‘中国’, 95);
insert into student (name, gj, score) values (‘hh’, ‘美国’, 85);
insert into student (name, gj, score) values (‘kk’, ‘俄罗斯’, 77);
select count(u.xm) as 总人数,
sum(decode(u.gj, 1, u.cj)) as 中国成绩,
sum(decode(u.gj, 2, u.cj)) as 美国成绩,
sum(decode(u.gj, 3, u.cj)) as 俄罗斯成绩
From (select name as xm,
decode(gj, ‘中国’, 1, ‘美国’, 2, ‘俄罗斯’, 3) as gj,
sum(score) as cj
from student
group by name,gj) u;
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://itzsg.com/50061.html