表结果是这样的
学号 课程 成绩
--------------------------
1 语文 93
1 数学 80
2 语文 86
2 数学 89查询结果为这样学号 语文 数学
--------------------------
1 93 80
2 86 89
学号 课程 成绩
--------------------------
1 语文 93
1 数学 80
2 语文 86
2 数学 89查询结果为这样学号 语文 数学
--------------------------
1 93 80
2 86 89
(select id,decode(course,'yuwen',score) yuwen,decode(course,'shuxue',score) shuxue
from tablename
)
group by id;
max(case when course='shuxue' then course end) shuxue
from tablename
group by id;我懒,所以楼主自己去改成中文
max(case when course='shuxue' then score end) shuxue
from tablename
group by id;
上面写错了