Skip to content
Advertisement

DB2 query with multiple WITH AS cases not compiling

For some reason, I can’t get this query to perform as I’m getting an error:

I’m running this in DB2 and I think this is occurring at either the very first line of the 2nd with/as at ) , A AS ( SELECT

Where am I going wrong?

Advertisement

Answer

It is always a good idea to use an SQL Editor that supports the version of Db2 that you are using.

Looking at your SQL in IBM Data Studio with the validation set to DB2 for i 7.2, highlights the following line in red underscores

Cross referencing to the manual, I can see that LEAD is supported in Db2 for i 7.3 but not Db2 for i 7.2

https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_74/db2/rbafzolapexp.htm

So that would be my guess at your syntax error

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement