postgresql - 我如何计算 Postgres 9.6 中唯一对的数量?

标签 postgresql

我想计算唯一对的数量。我正在尝试查询:

select count(distinct a, b) from t

但它给出了错误:

ERROR:  function count(integer, integer) does not exist

我该如何解决这个问题?

最佳答案

元组的语法是 (a, b)。因此你的查询应该是

select count (distinct (a, b)) ab_count from t

关于postgresql - 我如何计算 Postgres 9.6 中唯一对的数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50531424/

相关文章:

postgresql - 如何使用 Spring JpaRepository 转义问号 (?) 字符

laravel - 一小时间隔 - Laravel

database - PostgreSQL - 错误 : invalid privilege type CREATE for sequence

postgresql - Postgres 不知道在哪里可以找到服务器配置文件。 "brew install postgresql"之后

sql - PostgreSQL:所有文本列中的 ILIKE

sql - 如何在没有子查询的情况下依赖 DISTINCT ON

sql - 根据 id 列表为多条记录插入相同的值

postgresql - 半年(财政年度)的通用开始和结束日期,PostgreSQL

c# - 从BackgroundService创建DbContext租户时配置它

python - Django迁移数据库列顺序