I am trying to make a query that will compare first first condition was to compare the year now and get the maximum year of view view_delinquency_allquarter then, it will execute the first query else second query
BEGIN
IF
select max(ctaxyear) as ctaxyear,
(select cast ( (SELECT EXTRACT(QUARTER FROM TIMESTAMP 'now()')) as int ) as yearnow) as yearnow
from view_delinquency_allquarter
where ctaxyear > year_next
THEN
select * from view_delinquency_allquarter;
ELSE
select * from view_delinquency;
END IF;
END