课程种类固定的话到是可以使用 decode 结合数据表连接实现。

解决方案 »

  1.   

    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 学号, 姓名,专业,班级
      

  2.   

    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 学号,姓名
    ;
    你好,这是我刚刚遍的,不知道行不行.你试试!
             
      

  3.   

    你是不是再开发学校成绩管理程序,我能用pl/sql编过程 函数 触发器 可不可以和你一起干,你要是会开发前台的话那就更好了.我可以做数据库后台.
     
    有兴趣和我联系!
      

  4.   

    多谢诸位高手的帮助!!!在下有些疏忽,没把意思说明白,课程是需要动态地增加和删除的,假如新增加了一门课程“邓小平理论”,那么这条SQL语句就需要修改了。有没有办法在增加或删除课程后,不更改SQL语句呢?TO maohuijian(mao):
    在下还只是刚刚学习编程的菜鸟,还没有能力做大一点的程序,这只是一道练习题。希望日后有机会和阁下合作。