select 学号, 姓名,专业,班级,sum(decode(cou_name,'高等数学',result)) 高等数学 ,sum(decode(cou_name,'英语',result)) 英语 ,sum(decode(cou_name,'计算机',result)) 计算机 ,..... from (select stu_id,stu_name,d.spe_name,a.cla_id,f.cou_name,b.result from studentinfo a,resultinfo b,specourse c,specialtyinfo d,classinfo e,courseinfo f where a.stu_id=b.stu_id and b.cou_id=c.cou_id and c.cou_id=f.cou_id and c.spe_id=f.spe_id and c.spe_id=d.spe_id) group by 学号, 姓名,专业,班级
select stu.stu_id 学号,stu.stu_name 姓名,stu.cla_id 班级,spe.spe_name 专业, a.result 数学,b.result 英语,c.result 计算机 from resultinfo a,resultinfo b,resultinfo c,studentinfo stu,specourse spe,classinfo cla where a.cou_id=(select cou_id from courseinfo where cou_name='数学') and a.cou_id=(select cou_id from courseinfo where cou_name='英语') and a.cou_id=(select cou_id from courseinfo where cou_name='计算机') and a.stu_id=b.stu_id and b.stu_id=c.stu_id and stu.stu_id=a.stu_id and stu.stu_id=cla.cla_id and cla.spe_id=spe_id order by 学号,姓名 ; 你好,这是我刚刚遍的,不知道行不行.你试试!
,sum(decode(cou_name,'英语',result)) 英语
,sum(decode(cou_name,'计算机',result)) 计算机
,.....
from
(select stu_id,stu_name,d.spe_name,a.cla_id,f.cou_name,b.result from studentinfo a,resultinfo b,specourse c,specialtyinfo d,classinfo e,courseinfo f where a.stu_id=b.stu_id and b.cou_id=c.cou_id and c.cou_id=f.cou_id and c.spe_id=f.spe_id and c.spe_id=d.spe_id)
group by 学号, 姓名,专业,班级
where a.cou_id=(select cou_id from courseinfo where cou_name='数学') and
a.cou_id=(select cou_id from courseinfo where cou_name='英语') and
a.cou_id=(select cou_id from courseinfo where cou_name='计算机') and
a.stu_id=b.stu_id and b.stu_id=c.stu_id and stu.stu_id=a.stu_id and
stu.stu_id=cla.cla_id and cla.spe_id=spe_id
order by 学号,姓名
;
你好,这是我刚刚遍的,不知道行不行.你试试!
有兴趣和我联系!
在下还只是刚刚学习编程的菜鸟,还没有能力做大一点的程序,这只是一道练习题。希望日后有机会和阁下合作。