Re: How should I do this?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: How should I do this?
Дата
Msg-id 20020628121755.A15733@svana.org
обсуждение исходный текст
Ответ на Re: How should I do this?  (Laurent Duperval <lduperval@videotron.ca>)
Список pgsql-general
On Thu, Jun 27, 2002 at 08:55:23PM -0400, Laurent Duperval wrote:
> On Thu, 27 Jun 2002 12:53:21 -0400, Martijn van Oosterhout wrote:
>
> > Have a look at DISTINCT ON. It works well for this sort of thing.
> >
>
> Yes, but if I have
>
> 1 2 3
> 2 2 3
> 3 3 4
> 4 2 3
> 5 2 3
>
> I want
>
> 1 2 3
> 3 3 4
> 4 2 3
>
> left in the database. I think using distint on would yield
>
> 1 2 3
> 3 3 4

Ah right. The problem is that DISTINCT ON requires that the fields be
distincted on be the same and the first few fields being sorted by. In the
hypothetical case you could do:

select distinct on (col2) select * from a order by col1;

But that isn't allowed. Maybe you will be a stored procedure or something.

--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.



В списке pgsql-general по дате отправления:

Предыдущее
От: Curt Sampson
Дата:
Сообщение: Re: Shared Memory Sizing
Следующее
От: Justin Clift
Дата:
Сообщение: Suggestions for an update to the PHP manual?