S**H 发帖数: 1256 | 1 student course score
ZT 302 A
ZT 301 B
ZT 303 C
怎样写成这样的一行输出.
ZT A B C
谢谢!!!!
能不能不用cursor..... | j*****n 发帖数: 1781 | | p*********d 发帖数: 136 | 3 try this
select student,
wm_concat(course_301) c301,
wm_concat(course_302) c303,
wm_concat(course_303) c303
from
(select student,
decode(course, 301, score, null) course_301,
decode(course, 302, score, null) course_302,
decode(course, 303, score, null) course_303
from the_table)
group by student; | c********a 发帖数: 26 | 4 mysql里面有一个group_concat函数
select student, group_concat(score) from table group by student.
其他的数据库我就不知道了 | g***l 发帖数: 18555 | 5 老SQL两步倒,
select zt, case course when 301 then score else null end as 301score,
case course when 302 then score else null end as 302score,
case course when 303 then score else null end as 303score
into table1
from table
select zt, max(301score) as 301, max(302score as 302, max(303score) as 303
from
table1
group by zt |
|