create table hoge (year integer, month integer, amount integer);
create index hoge_idx on hoge(year, month);

select year, month, sum(amount)
from hoge where (year = 2017 and month > 3) or (year = 2018 and month < 4)
group by year, month;

実行計画:
https://explain.depesz.com/s/rwx