Postgres - count of GROUP BY
To count how many contributors have contributed 5 images or more:

SELECT COUNT(*) AS number_of_contributors
FROM
  ( SELECT 1
    FROM images 
    GROUP BY contributor_id
    HAVING COUNT(*) &gt;= 5
  ) AS t ;


It could be written without the derived table but it's obfuscated:

SELECT COUNT(*) OVER () AS number_of_contributors
FROM images 
GROUP BY contributor_id
HAVING COUNT(*) &gt;= 5 
LIMIT 1 ;


(there is a slight difference between the two queries. If there are no contributors with 5+ images, the first query will return one row with 0. The second query will return no rows.)