dimagi / django-cte

Common Table Expressions (CTE) for Django
Other
334 stars 46 forks source link

Mutiple CTEs Possible? #28

Closed jjorissen52 closed 3 years ago

jjorissen52 commented 3 years ago

Is it possible to use multiple CTEs in one query? E.g:

WITH your_cte_name AS (
    SELECT foo, bar
    FROM your_table
),
cte_number_2_name AS (
    SELECT foo
    FROM your_cte_name
)

SELECT * FROM cte_number_2_name
millerdev commented 3 years ago

Yes https://github.com/dimagi/django-cte/blob/fede416338ec0c5a967e2f1f902435061ae630e1/tests/test_cte.py#L242-L253

jjorissen52 commented 3 years ago

Awesome, thank you.