How do you delete duplicate rows in a table and still maintain one copy of the duplicate?
There are a couple of ways of doing this and approaches vary based on how big your table is,
whether you have constraints in place, how programming intensive you want to go,
whether you have a surrogate key and whether or not you have the luxury of taking a table down. Approaches
vary from using subselects, dropping a table and rebuilding using a distinct query from temp table,
and using non-set based approaches such as cursors.
The approach we often use is this one:
WHERE someuniquekey NOT IN
FROM sometable As dup
GROUP BY dup.dupcolumn1, dup.dupcolumn2, dup.dupcolum3)
Answer: In integer math, it is 1. A lot of people especially those coming from MySQL or MS Access backgrounds are surprised to find out that in PostgreSQL
3/2 = 1. They view this as some sort of bug.
In actuality, the fact that 3/2 = 1 and 1/3 = 0 is part of the ANSI/ISO-SQL standard
that states mathematical operations between two values must be of the same data type of one of the values (not necessarily the same scale and precision though). This is not some idiosyncracy specific to PostgreSQL.
If you try the same operation in SQL Server, SQLite,FireBird, and some other ANSI/ISO SQL compliant databases, you will get the same results. So it seems MySQL and MS Access are the odd-balls in this arena, but arguably more practical.