'PostgreSQL: with clause returning syntax error at end of input
I'm trying to create a temporary table with the following code:
with cte_counts as
(select entity_id, entity_name, count(distinct segment_id) as countries
from cte_geography
where cte_geography.metric_id in (2, 20, 35)
group by 1, 2
order by 3 desc)
select *
from cte_counts
but I get the error: ERROR: syntax error at end of input Position: 529
I've retyped it and I can't spot what's wrong. Without with, the code works fine:
select entity_id, entity_name, count(distinct segment_id)
from cte_geography
where cte_geography.metric_id in (2, 20, 35)
group by 1, 2
order by 3 desc
NOTE: performing this on Metabase.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
