代码之家  ›  专栏  ›  技术社区  ›  Fomalhaut

如何计算Postgres9.6中的唯一对数?

  •  1
  • Fomalhaut  · 技术社区  · 6 年前

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

    select count(distinct a, b) from t
    

    但它给出了错误:

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

    1 回复  |  直到 6 年前
        1
  •  3
  •   Haleemur Ali    6 年前

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

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