【和SQL对比】从分组子集中选出
每个部门出两名员工
SQL解法
select *
from (select 员工表.*,
row_number() over(partition by 部门 order by 1) 序号
from 员工表)
where 序号<=2
SQL处理从分组子集中再选出的任务需要使用子查询从源集合中再次查询。
select *
from (select 员工表.*,
row_number() over(partition by 部门 order by 1) 序号
from 员工表)
where 序号<=2
SQL处理从分组子集中再选出的任务需要使用子查询从源集合中再次查询。