【发布时间】:2021-07-07 19:44:50
【问题描述】:
Postgresql 有条件地在查询中包含 distinct
有没有办法修改查询,例如:
select distinct col1, col2
from our_schema.our_table
where (id = '1001')
目标是轻松激活/停用独特的关键字。
显然,可以将其移至如下评论:
select col1, col2 -- distinct
from our_schema.our_table
where (id = '1001')
在 Postgresql 中是否有任何简单的方法可以做到这一点?
我在使用 TSQL 语言的 Microsoft SSMS 中看到了“动态 SQL”。 Postgresql 有这样的东西吗?或者更简单的东西?
【问题讨论】:
-
你想申请什么条件?
-
另外,您如何/从哪里运行此查询?
-
条件是使用“distinct”关键字。我使用“dbeaver”数据库工具作为运行环境。
标签: postgresql distinct dynamic-sql database-programming