sqlserver 获取每组最接近某个时间点的一条数据
with T1 as ( SELECT ROW_NUMBER() over (PARTITION By MachineCode order by ABS(DATEDIFF(MILLISECOND,'2019-12-10 13:21:32.162' ,[Time]))) as rowid,* FROM EnergyConsumptions ) select * from T1 where rowid=1
Newd
版权声明
作者:も不秃不秃
地址:https://www.cnblogs.com/Newd/p/12932049.html
© Newd 尊重知识产权,引用请注出处
广告位
(虚位以待,如有需要请私信)