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