根据当前日期查询本季度的所有记录,非常实用.
以下提供两种用于ACCESS按季度查询记录的SQL语句,供大家参考.
1,查询当前季度所有记录
select * from news where DATEPART('q',time) = DATEPART('q',now()) And DATEPART('yyyy',time) = DATEPART('yyyy',now())
2,汇总并按季度显示所有数据
SELECT IIf(month(time) in (1,2,3),'一季度',IIf(month(time) in (4,5,6),'二季度',IIf(month(time) in (7,8,9),'三季度','四季度'))) AS Season, count(id) as hj, year(time) as nd FROM news GROUP BY year(time), IIf(month(time) in (1,2,3),'一季度',IIf(month(time) in (4,5,6),'二季度',IIf(month(time) in (7,8,9),'三季度','四季度')));
非常精典的按季度查询SQL语句,推荐收藏!
时间: 2025-01-20 19:50:47