How to delete rows number 2,3,4... - Mailing list pgsql-general

From A B
Subject How to delete rows number 2,3,4...
Date
Msg-id AANLkTimgpMYqNaHsVd_rAPb+LEYeoRbyLM+G=buOMX4j@mail.gmail.com
Whole thread Raw
Responses Re: How to delete rows number 2,3,4...
List pgsql-general
Hello.

I have a table

create table foo (
a serial,
b int,
c int,
.... more fields ...);

and now I wish to remove for each combination of b and c,  all the
rows except the one with the highest value of a.

For example
a  b  c  other fields
=====
1  5  5 .....
2  5  5 ....
3  2  3  ....
4  2  2  ...
5  5  5  ...

should leave

a  b  c  other fields
=====
3  2  3  ....
4  2  2  ...
5  5  5  ...

is there some clever command for this or will I have to write a
special function that loops through all values of  b and c ?

pgsql-general by date:

Previous
From: Timon
Date:
Subject: Fwd: stuck spinlock detected at dynahash.c
Next
From: Dave Page
Date:
Subject: Re: postgreSQL for Windows 7