首页 > 代码库 > SQL Server 按时间间隔提取数据进行数据采样

SQL Server 按时间间隔提取数据进行数据采样

Select Ana1,RdDate,RdTime,cast(convert(varchar,RdDate,112)+' '+convert(varchar,RdTime,108) as datetime) as time,t.interval FROM 
(SELECT Ana1,RdDate,RdTime, datediff (mi,cast(convert(varchar,RdDate,112)+' '+convert(varchar,RdTime,108) as datetime), GETDATE()) AS interval  
FROM Records ) AS t WHERE t.interval%10 = 0  //获取间隔十分钟的数据,但是获取之后分钟相同的还会有重复,仍需进一步处理

SQL Server 按时间间隔提取数据进行数据采样