**
select femail, min(fid) AS main_id, count(fid) AS countids
from users
where count(fid) > 1
group by femail
**
Of course, postgreSQL produce error for such wrong statement:
SQL error:
ERROR: aggregates not allowed in WHERE clauseI think it would be much better if DBMS will provide us some kind of suggestions, e.g.:
SQL error:
ERROR: aggregates not allowed in WHERE clause. Consider using HAVING clause.
--
Best regards,
Nikolay