When using the code below it creates the table even if no records are returned. Is there a way to tell to to only create the table if records are returned as the result of the WHERE clause? I want to use the table creation itself as a trigger for other processes
CREATE TABLE work.STF_2001 AS SELECT
FROM WORK.QUERY3723 AS QUERY3723
WHERE QUERY3723.Trigger = 0;
I think the DDL to create the table happens before the query is actually performed. For some codes, that's a shortcut to duplicate the table structure without copying data. For example, if you say
create table TABA as select * from TABB where 1=2;
You will get a copy of the table structure without any data.
I would think you'll have to use macros to check and see if there are records that match your criteria and only then would you create the table.