|
第二题 。。。
--
select c.lession_name
,e.stu_score1
,e.stu_score2
,e.stu_score3
from T_Lession c
,(select d.lession_id
,max(decode(d.rn,1,d.stu_id||'+'||d.score)) stu_score1
,max(decode(d.rn,2,d.stu_id||'+'||d.score)) stu_score2
,max(decode(d.rn,3,d.stu_id||'+'||d.score)) stu_score3
from (select a.stu_id
,a.stu_name
,b.lession_id
,b.score
,row_number() over (partition by b.lession_id order by b.score desc ) rn
from T_Stu_Profile a
,t_score b
where 1 = 1
and a.stu_id = b.stu_id
) d
where 1 = 1
and rn <= 3
group by d.lession_id
) e
where 1 = 1
and c.lession_id = e.lession_id(+)
order by c.lession_name ; |
|