Unanswered: Need help in writing a Netezza stored procedure
I have a SQL query which needs to run repeatedly by using different period_id from the year of 2014 to till 2016.
Query as follows
CREATE TABLE TABLE1
SELECT $PERIOD_ID AS PERIOD_ID
FROM (sub query) -- which includes period_id and joins with some other tables
UNION (sub query); --which includes period_id and joins with some other tables
I have a requirement to create a loop function to repeat from period id 201401 till 201609. How can i achieve this in a simplest way as i never tried writing SP in Netezza (NZsql). I thought of implementing the FOR loop but not getting exact code in my mind.
Any help and early response is really appreciated!
Thanks in advance. (Apologies if the query is confused).