30天以内:select count(*) from TB where datediff(day,字段名,getdate()) between 0 and 30
30-60天:select count(*) from TB where datediff(day,字段名,getdate()) between 30 and 60
60-90天:select count(*) from TB where datediff(day,字段名,getdate()) between 60 and 90
90天以外:select count(*) from TB where datediff(day,字段名,getdate())>90
计算数据库中30天以内,30-60天,60-90天,90天以外的数据的个数(用sql实现)
最新推荐文章于 2024-07-03 22:24:10 发布
本文介绍了一种使用SQL按不同时间段统计记录数量的方法,通过datediff函数结合getdate()函数实现对指定日期字段进行30天内、30-60天、60-90天及90天以上的数据量统计。
1550

被折叠的 条评论
为什么被折叠?



