User Profile
Collapse
-
Thank you for your efforts. :-) -
I found a better way to do it, by removing the WITH statement itself.
Thanks for your time and help.Code:insert into table1 ( select stateid, name, ssn from ( select row_number() over (partition by state) as num, stateid, name, ssn from state_population ) as data where num <= 10 )
Leave a comment:
-
-
The query does not execute and it gives the following error message:
SQL0199 - Keyword INSERT not expected. Valid tokens: ( SELECT VALUES.
State:37000,Nat ive:-199,Origin:[IBM][System i Access ODBC Driver][DB2 for i5/OS]Leave a comment:
-
Hi Rabbit,
Sorry I am new to this site, and did not see your posts about formatting the code. Will ensure I format the code part going forward.
Anyway, the option you have mentioned was tried the very first time before posting this query. That one too isn't working.
...Code:with data ( select row_number() over (partition by state) as num, stateid, name, ssn from state_population ) insert
Leave a comment:
-
I tried the following 2 alternatives:
1.
2.Code:with data ( insert into table1 (stid, pname, pssn) ( select row_number() over (partition by state) as num, stateid, name, ssn from state_population ) select stateid, name, ssn from data where num <= 10 )
...Code:with data insert into table1 (stid, pname, pssn) ( ( select row_number() over (partition by state)
Last edited by Rabbit; Sep 26 '13, 03:47 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data. Third and final warning.Leave a comment:
-
Code:insert into table1 (stid, pname, pssn) ( with data ( select row_number() over (partition by state) as num, stateid, name, ssn from state_population ) select stateid, name, ssn from data where num <= 10 )
Last edited by Rabbit; Sep 26 '13, 01:10 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data. Second Warning.Leave a comment:
-
Hi Rabbit.
I m using Query Tool to query the database (DB2 for OS400), and the above query works. However, when I add the insert query on top of it, it throws an error.
Keyword WITH not expected. Valid tokens: ( SELECT VALUES.Leave a comment:
-
Insert rows into a table by 'With' clause
Hi,
I have a database from which I am retrieving first 10 rows for each group using the 'With' table clause.
e.g
I want to insert the rows retrieved from above query into another table.Code:with data ( select row_number() over (partition by state) as num, state id, name, ssn from state_population ) select * from data where num <= 10
Can someone help me with this?
...Last edited by Rabbit; Sep 25 '13, 08:50 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
No activity results to display
Show More
Leave a comment: