1.Excel导入到数据库my表,导出科室字段相同的2条随机记录
select * from (
select *, ROW_NUMBER() over(partition by 科室) rowNum
from my
) as s where s.rowNum<=40
2.Excel导入到数据库my表,导出科室字段相同的按time正序排列的前2条记录
select * from (
select *, ROW_NUMBER() over(partition by 科室 order by time asc) rowNum
from my
) as s where s.rowNum<=2