【发布时间】:2017-04-19 21:32:02
【问题描述】:
这是我在 select 语句中的 sql 示例。从 oracle 转换为 postgres,需要一种简单的方法来在 postgres 中重新实现 oracle count distinct over partition。
, count(distinct on pm.mobseg_state) over (partition by pm.trans_id) as mob_segments_count
, count(distinct on pm.country_reg_region_cd) over (partition by pm.trans_id) as countries_count
【问题讨论】:
-
我认为您不能在 Oracle 或 Postgres 的窗口函数中使用
distinct。 -
目前在 oracle 中工作。为 postgres 寻找解决方法。
标签: sql oracle postgresql