How to delete rows number 2,3,4...

Поиск
Список
Период
Сортировка
От A B
Тема How to delete rows number 2,3,4...
Дата
Msg-id AANLkTimgpMYqNaHsVd_rAPb+LEYeoRbyLM+G=buOMX4j@mail.gmail.com
обсуждение исходный текст
Ответы Re: How to delete rows number 2,3,4...  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Список 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 по дате отправления:

Предыдущее
От: Timon
Дата:
Сообщение: Fwd: stuck spinlock detected at dynahash.c
Следующее
От: Dave Page
Дата:
Сообщение: Re: postgreSQL for Windows 7