GitHub user dosubot[bot] added a comment to the discussion: Working with CTES in Superset
<!-- Answer --> Yes, you can use CTEs (Common Table Expressions) in Superset. You can write queries with CTEs in SQL Lab, save them as datasets, and then use those datasets to build charts. Superset treats CTEs as standard SQL, so as long as your database supports them, there are no restrictions from Superset itself. For more details and examples, see this discussion and code references: [discussion on using CTEs in SQL Lab](https://github.com/apache/superset/discussions/31818), [CTEs as a workaround for DECLARE statements](https://github.com/apache/superset/issues/31913), and [code support for saving and reusing queries with CTEs](https://github.com/apache/superset/blob/6876a1e6843cd1f28f4206ca2dd75342dfddcf26/superset/models/sql_lab.py). If you need a workflow: write your CTE query in SQL Lab, use "Save Dataset," and then select that dataset when creating a chart. Let me know if you need more details or a step-by-step! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/6c5867c0-5f00-4daf-a812-89bad86f3298?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/6c5867c0-5f00-4daf-a812-89bad86f3298?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/6c5867c0-5f00-4daf-a812-89bad86f3298?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/6c5867c0-5f00-4daf-a812-89bad86f3298?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6c5867c0-5f00-4daf-a812-89bad86f3298?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/6c5867c0-5f00-4daf-a812-89bad86f3298?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/6c5867c0-5f00-4daf-a812-89bad86f3298?feedback_type=other)</sup> [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/33899) GitHub link: https://github.com/apache/superset/discussions/33899#discussioncomment-13571234 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
