日期:2014-05-17  浏览次数:20738 次

group by 后选取每一类前三个插入另一个表中
如题,表为EMP(ename,sal,score)
将各个职位成绩前3位的职员的姓名,工资,成绩,名次存到一个数据表GOOD中。

不知道在group by 和Order by之后怎么选取每一类的前三个啊?
rownum貌似不对啊。

------解决方案--------------------
insert into good
select * from (
select * row_number() over(partition by 职位 order by score desc) sc_order from emp
)
where sc_order <= 3