Search code examples
sqlsyntaxdb2derby

In-line temporary tables in Derby (like DB2)


Does Derby have an equivalent syntax for in-line temporary tables such as these:

(this is valid DB2 syntax):

    with data(a,b) as (values
                        ('a',10),
                        ('b',20),
                        ('c',30),
                        ('d',40)
                      )
    select * from data 

Thanks,

Pradyumna


Solution

  • I'm not quite sure if this is what you're trying to achieve, but this works in Derby:

    select a,b from (values ('a', 10), ('b', 20), ('c', 30)) as x(a,b);