以下提供兩種用於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),'三季度','四季度')));