我尝试使用以下代码创建一个临时表:
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
但我得到了错误:ERROR:输入结束时语法错误位置:529
我把它重新打了一遍,但我找不出哪里有错。没有***和***,代码工作正常:
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
注意:在Metabase上执行此操作。
1条答案
按热度按时间vx6bjr1n1#
我在创建CTE时遇到了类似的问题。我在最后得到了一个语法错误)。我尝试了@AdrianKlaver建议并添加的内容;)选择 * From CTE。在那之后它工作得很完美。