<p>The database type is PostGres 8.3.</p>

<p>If I wrote: </p>

<pre><code>SELECT field1, field2, field3, count(*) 
FROM table1
GROUP BY field1, field2, field3 having count(*) &gt; 1;
</code></pre>

<p>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.)</p>

<p>Example:</p>

<pre><code>1-2-3
1-2-3
1-2-3
2-3-4
4-5-6
</code></pre>

<p>Should become :</p>

<pre><code>1-2-3
2-3-4
4-5-6
</code></pre>

<p><em>The only answer I found is <a href="http://www.siafoo.net/article/64" rel="noreferrer">there</a> but I am wondering if I could do it without hash column.</em></p>

<p><strong>Warning</strong>
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.</p>

One possible answer is:
```
```
CREATE <temporary table> (<correct structure for table being cleaned>);
BEGIN WORK;   -- if needed
INSERT INTO <temporary table> SELECT DISTINCT * FROM <source table>;
DELETE FROM <source table>
INSERT INTO <source table> SELECT * FROM <temporary table>;
COMMIT WORK;  -- needed
DROP <temporary table>;
```
```
I'm not sure whether the 'work' is needed on transaction statements, nor whether the explicit BEGIN is necessary in PostgreSQL.  But the concept applies to any DBMS.
The only thing to beware of is referential constraints and in particular triggered delete operations.  If those exist, this may prove less satisfactory.