sql里的ROW_NUMBER() OVER是啥意思?
是一个分析函数,生成一个排序列
select row_number(XX) over(partition by XXX order by XX [desc/asc]) frou table;
partition by 是用来分组的,用了这个就可以实现在组内进行排序
order by是用来确定排序的基准的,按照那一列来排序
抗菌药物监测- 04围手术期目标监测报表
--时间段内有多条手术记录取该时间段内手术时间最早1条记录
INSERT INTO #t_qb
SELECT SYXH ,KSDM ,KSMC ,CW ,HZXM ,BLH ,BRNL ,BRXB ,RYRQ ,SSRQ ,QKDJ ,MZSJ ,MZJSSJ ,SSKSSJ ,SSJSSJ ,SJC ,KSSZXSJ ,YSDM
FROM ( SELECT ROW_NUMBER() OVER ( PARTITION BY SYXH ORDER BY SSRQ ASC ) AS Num , *
FROM #t_qb_temp ) a --where a.Num = 1