Postgres Select Rows With Duplicate Checker