表结果是这样的
学号    课程    成绩
--------------------------
1         语文    93
1         数学    80
2         语文    86
2         数学    89查询结果为这样学号      语文      数学
--------------------------
1          93        80
2          86        89

解决方案 »

  1.   

    select id,max(yuwen) yuwen,max(shuxue) shuxue
    (select id,decode(course,'yuwen',score) yuwen,decode(course,'shuxue',score) shuxue
    from tablename
    )
    group by id;
      

  2.   

    select id,max(case when course='yuwen' then course end) yuwen,
           max(case when course='shuxue' then course end) shuxue
    from tablename
    group by id;我懒,所以楼主自己去改成中文
      

  3.   

    select id,max(case when course='yuwen' then score end) yuwen,
           max(case when course='shuxue' then score end) shuxue
    from tablename
    group by id;
    上面写错了