syntax error at or near “union“"/>
syntax error at or near “union“
postgreSQL 使用union时遇到了一个问题:
syntax error at or near "union"
1. 问题 sql 如下:
select tech_model as model from dim_product_attribute_acc where tech_model is not null group by tech_model order by tech_modelunionselect 'N/A' as model
2. 原因
order by 的问题
order by 不能 和 union 同时使用
正解如下:
with tem as(select tech_model as model from dim_product_attribute_acc where tech_model is not null group by tech_model order by tech_model
)
select model from tem
union
select 'N/A' as model
把order 放到外层即可。
更多推荐
syntax error at or near “union“
发布评论