sql - org.postgresql.util.PSQLException:错误:没有为窗口函数实现 DISTINCT
问题描述
这个 SQL
SELECT COUNT(DISTINCT(FOO)) over (PARTITION BY NULL) as bar
导致错误
org.postgresql.util.PSQLException: ERROR: DISTINCT is not implemented for window functions
在stackoverflow上解决这个错误似乎没有任何答案。
解决方案
固定的
将 SQL 更改为SELECT COUNT(FOO) over (PARTITION BY NULL) as bar
Postgres 不喜欢在 COUNT 之后有 DISTINCT,并且当没有 DISTINCT 时会将其视为一个函数。
推荐阅读
- java - 如何以编程方式从android应用程序的文件和文件夹中删除世界读/写权限?
- ios - iOS Firestore 可以将 `FieldValue.increment` 用于 Map 值吗?
- javascript - Google Places API 上的 CORS 错误,但 Reddit 上没有
- python - Pyperclip 模块在 Android 上失败
- java - 如何知道背包问题(DP实现)中选择了哪个项目?
- vue.js - Parcel vue 调试:如何将 parcel serve 的输出映射到我的源代码?
- java - Spring Batch:如何配置 FlatItemFileReader 来读取压缩的 ND-JSON 文件?
- visual-studio - 在 Visual Studio 2013 中找不到这些选项
- python - 如何通过根据值字典的长度对嵌套字典进行排序来创建排序字典?
- java - 传递给新活动的数据为空