The database type is PostGres 8.3.
If I wrote:
SELECT field1, field2, field3, count(*) FROM table1 GROUP BY field1, field2, field3 having count(*) > 1;
I have some rows that have a count over 1. How can I take out the duplicate (I do still want 1 row for each of them instead of +1 row… I do not want to delete them all.)
Example:
1-2-3 1-2-3 1-2-3 2-3-4 4-5-6
Should become :
1-2-3 2-3-4 4-5-6
The only answer I found is there but I am wondering if I could do it without hash column.
Warning I do not have a PK with an unique number so I can’t use the technique of min(…). The PK is the 3 fields.
This is one of many reasons that all tables should have a primary key (not necessarily an ID number or IDENTITY, but a combination of one or more columns that uniquely identifies a row and which has its uniqueness enforced in the database).
Your best bet is something like this: