使用PostgreSQL使用(CTE)在中创建

使用PostgreSQL使用(CTE)在中创建,postgresql,Postgresql,我正在尝试使用PostgreSQL中的函数在中创建临时表 示例: with mm as ( select * from test ) create table xyz as select * from mm ; 注意:在创建附近获取错误 create table xyz as with mm as ( select * from test ) select * from mm where myfield = myvalue ; 相关的。在文档中,没有明确说明如何将创

我正在尝试使用PostgreSQL中的函数在中创建临时表

示例

with mm
as
(
     select * from test
)
create table xyz as select * from mm
;
注意:在创建附近获取错误

create table xyz as 

with mm
as
(
     select * from test
)
select * from mm 
where myfield = myvalue
;
相关的。在文档中,没有明确说明如何将
创建表作为
与CTE一起使用。但是,它清楚地说明了它的语法(简化):

查询可以在哪里(引用):

SELECT、TABLE或VALUES命令,或运行 已准备好选择、表或值查询


由此看来,您的尝试失败的原因应该非常清楚。

根据您的说法,“从mm中选择*select”后面应该是“WHERE”,对吗?@Meen是的,没错,我在答案中添加了简单的WHERE条件。是的!我得到了它。非常感谢你。
CREATE TABLE table_name
    AS query