Multiple CTE's in native query?

Is there a bug or limitation on having multiple CTE's in a native query? I'm just doing two separate CTE statements, but it is not recognizing the second CTE statement, instead telling me that "Error: syntax error at or near WITH position".

This is basically the format I have
with cte_1 as (select * from x),
with cte_2 as (select * from y)

select * from x_test a
join y_test b on a.keytojoin= b.keytojoin

(This is something that can't be done with a subquery unfortunately, in this case)

EDIT: I should add that queries with one CTE work fine, it's an issue only with multiple CTE's

Hi @saaballergies
Try looking in your database documentation.
You only have a single WITH-clause usually:
https://www.metabase.com/learn/sql-questions/sql-cte#using-multiple-ctes-in-a-single-query

1 Like

Thank you! This was my fault for including the extra with statement.