I’ve got a table with 6 columns:
idnametype_idcodelatlong
The first three are required. ID is the private key, inserted automatically with a sequence.
I have some rows that are duplicates, as defined by BOTH the name and type_id being equal, but i’d like to view all the data for the dupes. I can find the dupes simply enough:
SELECT name
, type_id
FROM table1
GROUP BY name
, type_id
HAVING COUNT(*) > 1
but actually viewing all the info is confounding me. I know this should be simple, but I’m hitting a wall here.
You can always use the
GROUP BY/HAVINGquery in an IN clause. This works and is relatively straightforward but it may not be particularly efficient if the number of duplicate rows is relatively large.It would generally be more efficient to use analytic functions in order to avoid hitting the table a second time.
Depending on what you are planning to do with the data and how many duplicates of a particular row there might be, you also might want to join
table1to itself to get the data in a single row