Re: [GENERAL] Delete Duplicates with Using

2017-10-16 Thread Igal @ Lucee.org
FYI, On 10/16/2017 8:58 AM, Igal @ Lucee.org wrote: test=*# with keep as (select max(ctid) as ctid from dubletten group by c1,c2,c3) delete from dubletten where ctid not in (select ctid from keep); I like this solution, but would using a subquery be much slower than the implicit join

Re: [GENERAL] Delete Duplicates with Using

2017-10-16 Thread Igal @ Lucee.org
Andreas, On 10/15/2017 11:53 PM, Andreas Kretschmer wrote: other solution, using the CTID-column: (rows with (1,1,1) and (5,5,5) are identical) test=*# select * from dubletten ;  c1 | c2 | c3 ++   1 |  1 |  1   1 |  1 |  1   1 |  2 |  3   2 |  3 |  4   3 |  4 |  5   4 |  5 |  5  

Re: [GENERAL] Delete Duplicates with Using

2017-10-16 Thread Andreas Kretschmer
Am 14.10.2017 um 08:20 schrieb Igal @ Lucee.org: Hello, I run the SQL query below to delete duplicates from a table. The subquery is used to identify the duplicated rows (row_num is a BIGSERIAL column). other solution, using the CTID-column: (rows with (1,1,1) and (5,5,5) are

Re: [GENERAL] Delete Duplicates with Using

2017-10-15 Thread Igal @ Lucee.org
On 10/14/2017 12:32 AM, legrand legrand wrote: DELETE FROM table_with_duplicates AS T1 USING table_with_duplicates AS T2 WHERE T1.column_1 = T2.column_1 AND T1.column_2 = T2.column_2 AND T1.column_3 = T2.column_3 AND T1.row_num < T2.row_num Thank you, I

Re: [GENERAL] Delete Duplicates with Using

2017-10-14 Thread legrand legrand
DELETE FROM table_with_duplicates AS T1 USING table_with_duplicates AS T2 WHERE T1.column_1 = T2.column_1 AND T1.column_2 = T2.column_2 AND T1.column_3 = T2.column_3 AND T1.row_num < T2.row_num -- Sent from:

[GENERAL] Delete Duplicates with Using

2017-10-14 Thread Igal @ Lucee.org
Hello, I run the SQL query below to delete duplicates from a table.  The subquery is used to identify the duplicated rows (row_num is a BIGSERIAL column). /** delete older copies of duplicates */ DELETE FROM table_with_duplicatesAS T WHERE row_num IN (     SELECT     T1.row_num     FROM