我有一個查詢,我算的行數每年學年:集團在Postgres的
SELECT
count(*) as activation_count
, extract(year from activated_at) as year
FROM "activations"
WHERE ...
GROUP BY year
,但我想,而不是有多年爲從九月到九月,而不是1至1月。因此按學校年代而不是日曆年進行分組。
我可以修改我的查詢嗎?
而且更普遍,是可以按時間範圍,並指定偏移到它,比如:extract(year from activated_at offset interval 2 month) as year
(這是行不通的,只是我想要什麼的想法)