SQLServer 每隔10分钟取一条数据

开发中遇到10Min中取一条数据,设备数据是1分钟上传一次

SQLServer 每隔10分钟取一条数据_第1张图片


SQLServer 每隔10分钟取一条数据_第2张图片



coding....


;With Pit_intrvl_CTE As
(
Select 
 I.[ColTime]
 , DATEPART(MINUTE, I.[ColTime]) Minute
 , DATEPART(MINUTE, I.[ColTime])%10 Mod5
 , DATEPART(MINUTE, I.[ColTime])- DATEPART(MINUTE, I.[ColTime])%10 Intrv_grp
 , I.[FieldValue]
From [KS_DataBase2017].[dbo].[KS_EquipRec20171130] I WHERE I.EquipMentID =1 
)


--Select * from Pit_intrvl_CTE order by [ColTime] -- shows full results


Select [ColTime],[FieldValue] from Pit_intrvl_CTE where Mod5 = 0 Group by [ColTime],[FieldValue] order by [ColTime]


你可能感兴趣的:(SQLServer 每隔10分钟取一条数据)