Subject Annoying: CTE "CTE2" is not used in query
Author Louis van Alphen

See the following SQL below.

If I select from COMBINED, the sql runs but as below I get an error. This is pretty annoying when constructing a large SQL with many CTEs and you want to test each one and combinations of them. I can get why the error is there, but any other suggestion?

 

with

CTE1 as

(

  select 1 as ID from rdb$database

),

CTE2 as

(

  select 2 as ID from rdb$database

),

 

COMBINED as

(

  select * from CTE1

    union

  select * from CTE2

)

 

select * from CTE1