user1800967 user1800967 - 20 days ago 6
SQL Question

Netezza insert into error

Working in Netezza and trying to run the following query:

CREATE TEMP TABLE COUNTS
AS SELECT COUNT(*) AS ROWCOUNT, 'CA' AS PLAN FROM TABLE1;

INSERT INTO COUNTS
(SELECT COUNT(*) FROM TABLE2, 'FL');

SELECT * FROM COUNTS;


But for some reason, it doesn't like the 'FL' part and if I remove it:

INSERT INTO COUNTS
(SELECT COUNT(*) FROM TABLE2);


it runs fine but with a NULL where I wanted FL to be.

I don't know what's going on. Any help is greatly appreciated. Thank you very much in advance!

Answer

could be you must declare the column explicitally

 INSERT INTO COUNTS(ROWCOUNT, PLAN)
 SELECT COUNT(*), 'FL' FROM TABLE2';