0

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

1 Answer 1

0

There are plenty of answers as well as documentation use declare var and then assignment var := (your query result)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.