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