Re: Ordering of records in group by not possible

From: Ludwig Isaac Lim <ludz_lim(at)yahoo(dot)com>
To: Chris Kratz <chris(dot)kratz(at)vistashare(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Ordering of records in group by not possible
Date: 2006-04-26 15:19:10
Message-ID: 20060426151910.84712.qmail@web33111.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi:

> 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
>

another alternative is :

select a , aggregrate(b) as <alias>
from c
group by a
order by a, <alias>

e.g.

select a,sum(b) as sum_b
from c
group by a
order by a, sum_b

ludwig lim

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Kratz 2006-04-26 15:21:33 Re: Ordering of records in group by not possible
Previous Message SunWuKung 2006-04-26 14:57:59 evaluating equation stored in a string