Postgresql Count If Not Duplicate