日期:2014-05-17 浏览次数:20753 次
with t as
(select 1 as ID, 'Java' as course, 'Jim' as name, '80' as score
from dual
union all
select 2 as ID, 'Java' as course, 'Lilei' as name, '90' as score
from dual
union all
select 3 as ID, 'Java' as course, 'Hanmeimei' as name, '60' as score
from dual
union all
select 4 as ID, 'C' as course, 'Tom' as name, '100' as score from dual
)
select name
from (select name,
row_number() over(partition by course order by score desc) as rn
from t
where course = 'Java')
where rn = 2;
with t as
(select 1 as ID, 'Java' as course, 'Jim' as name, '80' as score
from dual