简体   繁体   中英

org.postgresql.util.PSQLException: ERROR: DISTINCT is not implemented for window functions

This SQL

SELECT COUNT(DISTINCT(FOO)) over (PARTITION BY NULL) as bar

causes the error

org.postgresql.util.PSQLException: ERROR: DISTINCT is not implemented for window functions

There doesnt seem to be any answers to solving this error on stackoverflow.

Fixed

Change the SQL to SELECT COUNT(FOO) over (PARTITION BY NULL) as bar

Postgres doesnt like having DISTINCT after COUNT and will treat DISTINCT as a function, when there isn't one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM