Can you use CTE with variables?

Can you pass variables to a common table expression (CTE)? I have an SQL query that I want to call from other queries. The CTE works great for this. But I also need to pass variables to the CTE (a date range in case it matters). Is this possible? If there's another way to filter the CTE from the new query that'd be just as helpful.

Metabase version v0.42.3

Hi @CrossingChalk
Yes, you can use Field Filters inside of the CTE, but you cannot use it outside the CTE, since that CTE is a table alias.

1 Like