Thursday, October 2, 2014

Menghapus Duplikat data pada postgresql

Berikut Contoh Syntax nya :

DELETE FROM tab 
  WHERE id IN (SELECT id 
                  FROM (SELECT row_number() OVER (PARTITION BY column_with_duplicate_values), id 
                           FROM tab) x 
                 WHERE x.row_number > 1);

No comments:

Post a Comment