Query to fetch term from gl_periods
Need your help to extract specific terms from gl_periods based on given 2 periods
TERM1 : APR to SEP
TERM2 : OCT to MAR
If we input 'DEC-12' & 'FEB-13' >> expected result should be from OCT-12 to MAR-13 (6 months) (1 term)
If we input 'SEP-12' & 'APR-13' >> expected result should be from APR-12 to SEP-13 (18 months) (3 terms)
select period_year, period_name,decode(QUARTER_NUM,1,'TERM1',2,'TERM1',3,'TERM2',4,'TERM2') TERM, QUARTER_NUM
from gl_periods
where adjustment_period_flag='N'
and period_set_name='TSE ACCOUNTING'
and period_year in(select distinct period_year from gl_periods where period_name in ('DEC-12','FEB-13'))