Saturday, 7 September 2013

How to count duplicate rows (and remove duplicates)?

How to count duplicate rows (and remove duplicates)?

Is there a generic SELECT statement to detect duplicate rows ("identical",
where all columns are equal)? E.G, columns 2 & 4 in the following table
titel | interpret | jahr
-----------------------------------+------------------+-----
Beauty | Ryuichi Sakamoto | 1990
Goodbye Country (Hello Nightclub) | Groove Armada | 2001
Glee | Bran Van 3000 | 1997
Goodbye Country (Hello Nightclub)| Groove Armada | 2001
Or do I need a SELECT which is specific to the table?
Someone has given me an Sqlite d/b with multiple tables each of which look
like like they have multiple identical rows (with different columns in
each table), so I would prefer a generic solution.
After that, I have to figure out how to delete the duplicates. Maybe I can
use DISTINCT on the SELECT, store in a temp table, delete the original and
rename the temp table?

No comments:

Post a Comment