Re: Do AGGREGATES consistently use sort order?

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: Do AGGREGATES consistently use sort order?
Дата
Msg-id 87ps0vznqy.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Do AGGREGATES consistently use sort order?  ("Webb Sprague" <webb.sprague@gmail.com>)
Ответы Re: Do AGGREGATES consistently use sort order?  ("Webb Sprague" <webb.sprague@gmail.com>)
Список pgsql-general
"Webb Sprague" <webb.sprague@gmail.com> writes:

> I can always count on (note the order name):
>
> \a
> oregon_2007_08_20=# select array_accum(name) from (select name from
> placenames where desig='crater' order by name desc) a;
> array_accum
> {"Yapoah Crater","West Crater","Twin Craters","Timber Crater","Red
> Crater","Newberry Crater","Nash Crater","Mount Mazama","Millican
> Crater","Little Nash Crater","Le Conte Crater","Jordan
> Craters","Diamond Craters","Coffeepot Crater","Cayuse Crater","Black
> Crater","Big Hole","Belknap Crater"}
> (1 row)
>
> I am interested in stitching a line out of points in postgis, but the
> order/aggregate thing is a general question.

Yes.

You can even do this with GROUP BY as long as the leading columns of the ORDER
BY inside the subquery exactly matches the GROUP BY columns.

In theory we can't promise anything about future versions of Postgres but
there are lots of people doing this already so if ever this was lost there
would probably be some new explicit way to achieve the same thing.

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

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

Предыдущее
От: "George Pavlov"
Дата:
Сообщение: Re: Alias "all fields"?
Следующее
От: Ron Johnson
Дата:
Сообщение: Re: a provocative question?