Re: Ordering of records in group by not possible

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Ordering of records in group by not possible
Дата
Msg-id 444F841D.2030500@magproductions.nl
обсуждение исходный текст
Ответ на Ordering of records in group by not possible  (Chris Kratz <chris.kratz@vistashare.com>)
Ответы Re: Ordering of records in group by not possible  (Ludwig Isaac Lim <ludz_lim@yahoo.com>)
Re: Ordering of records in group by not possible  (Chris Kratz <chris.kratz@vistashare.com>)
Список pgsql-general
Chris Kratz wrote:
> Hello all,
>
> I wanted to verify what we are seeing.
>
> Select a, aggregate(b)
> from c
> group by a
> order by a,b

That's a rather odd query... Values in b aren't available to order by,
as they have been aggregated. There is no relation to the values in b
and the values in your result set.

You could order by "column 2" if you want to order on the results on
your aggregate:
    Select a, aggregate(b)
    from c
    group by a
    order by a,2

--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
    7500 AK Enschede

// Integrate Your World //

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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Ordering of records in group by not possible
Следующее
От: Tony Caduto
Дата:
Сообщение: Question about postgresql.conf memory settings