Search Postgresql Archives

Re: Adding PRIMARY KEY: Table contains duplicated values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/04/2013 06:45 AM, Alexander Farber wrote:
Trying to delete the older of the duplicated pairs:

# SELECT id, author, count(1), max(stamp) as maxx
   FROM pref_rep
GROUP BY id, author
HAVING count(1) >1 and stamp < maxx;
ERROR:  column "maxx" does not exist
LINE 4: HAVING count(1) >1 and stamp < maxx;

How about:
SELECT id, author, count(1), max(stamp) as maxx
  FROM pref_rep
GROUP BY id, author
HAVING count(1) >1 and stamp < max(stamp);

                                        ^

On Mon, Feb 4, 2013 at 3:36 PM, Alexander Farber
<alexander.farber@xxxxxxxxx> wrote:
http://stackoverflow.com/questions/14688523/adding-primary-key-table-contains-duplicated-values





--
Adrian Klaver
adrian.klaver@xxxxxxxxx


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux