sql按月查詢


//按月查詢
select  from  tb  where  convert ( varchar (7), date ,120) =  '2011-05'
select  from  tb  where  convert ( varchar(10) , date ,120) =  '2011-05-01'
 
//按小時分組,求得每個分組后的個數

SELECT datepart(hour,a.VelPassTime),count(*) num from VelOriginalData a
where a.SensorCommonId = 'f7fb8929-1e58-42c1-9d13-052ddfc82136' and a.VelPassTime >= '2020-04-13 00:00:00' and a.VelPassTime <= '2020-04-14 00:00:00'
and a.VelLoad >= 0 and a.VelLoad <= 10000
group by datepart(hour,a.VelPassTime)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM