sqldbeaver

DBeaver SQL Error [102] [S0001]: Incorrect syntax near ')'


Asuming the following SQL code in DBeaver 23.2.1

with CTE1 as (
    select Col1, Col2, Col3 
    from View1
),
CTE2 as (
    select Col1 
    from View2
),
CTE3 as (
    select Col1 
    from View3
)

It produces the following output in DBeaver 23.2.1 but works just fine in MSSMS:

SQL Error [102] [S0001]: Incorrect syntax near ')'.

The last closing parenthesis is marked as syntax error. Is there something I'm missing?

enter image description here


Solution

  • A WITHclause isn't a complete query, you have to SELECT too. Something like

    with CTE1 as (
        select Col1, Col2, Col3 
        from View1
    ),
    CTE2 as (
        select Col1 
        from View2
    ),
    CTE3 as (
        select Col1 
        from View3
    )
    select ...
    from CTE1 ...