1.ROW_NUMBER() OVER()- 分组取前几条数据
select * from (select id , ROW_NUMBER() OVER(partition by 分组列名 order by 排序列名) as RN) where RN < 每组所取数量
2.WM_CONCAT()-几条数据形成一字符串
SELECT H_ID,wm_concat(dp_deptname) as coredepts FROM (SELECT H_ID,dp_deptname,ROW_NUMBER() OVER(partition BY H_ID ORDER BY D_CERT) AS RN
FROM HIS_DEPT) WHERE RN <= 3 group by H_ID