--班级表 create table CLASS ( ID VARCHAR2(5) not null primary key, CLASSNAME VARCHAR2(10) ); --学生表 create table STUDENT ( ID VARCHAR2(10) not null primary key, NAME VARCHAR2(10), AGE NUMBER(3), CLASSID VARCHAR2(5) ); --科目表 create table subject( id varchar2(10) primary key, subname varchar2(10) ); --分数表 create table score( sid varchar2(4), subid varchar2(10), score number(4,1) );
select s1.name 姓名,
s1.age 年龄,
s1.classname 班级,
score_.sid,
数学,
语文,
物理,
化学,
(数学 + 语文 + 物理 + 化学) 总分
from (select s.sid,
sum(decode(s.subid, 'SUB001', s.score)) 数学,
sum(decode(s.subid, 'SUB002', s.score)) 语文,
sum(decode(s.subid, 'SUB003', s.score)) 物理,
sum(decode(s.subid,'SUB004',s.score)) 化学
from score s
group by s.sid) score_
right join (select st.id, st.name, st.age, c.classname
from student st, class c
where c.id = st.classid) s1 on s1.id = score_.sid
order by 总分;
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有