0
我有下面的查询返回12个月的滚动数据。因此,如果我今天运行它,它会将数据从2015年8月23日带回到2016年8月23日。现在理想情况下,我希望它从2015年8月1日开始,如果我要在下个月再次运行,它将从2015年9月1日开始运行。这可能吗?谢谢12个月滚动
select
Date
Street
Town
Incidents
IncidentType A
IncidentType B
IncidentType C
FROM
(
select
COUNT(I.INC_NUM) as Incidents,
COUNT(case when i.INC_TYPE = ''A'' THEN 1
end)
"IncidentType A"
COUNT(case when i.INC_TYPE = ''B'' THEN 1
end)
"IncidentType B"
COUNT(case when i.INC_TYPE = ''C'' THEN 1
end)
"IncidentType C"
FROM Table i
GROUP BY i.INC_NUM
) i
where Date >= (now()-('12 months'::interval))
请与您正在使用的数据库标记您的问题。 –