SQL Server中時間按天分組


例1:

select Min(VisitTime),count(*) as Num from online group by datediff(day,VisitTime,getdate())

例2:

select count(*),Min(PayTime) from LimitBidBills where PayTime>'2020-07-25' and Status='已確認'
group by datediff(day,PayTime,getdate())
order by Min(PayTime) asc

例3:

select count(*),Min(PayTime) from LimitBidBills join LimitBidMail on LimitBidBills.InfoID = LimitBidMail.InfoID where PayTime>'2020-06-20' and   PayTime<'2020-07-5' and Status='已確認'
group by datediff(day,PayTime,getdate())
order by Min(PayTime) asc

 


免責聲明!

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



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