From: | "T(dot)J(dot) Adami" <adamitj(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: COUNT() with ORDER BY |
Date: | 2008-01-15 12:26:37 |
Message-ID: | 6338c084-439c-44cf-a255-527404f23a33@d4g2000prg.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 14 jan, 17:02, "Andrus" <kobrule(dot)(dot)(dot)(at)hot(dot)ee> wrote:
> create temp table test (col char);
> select count(col) from test order by col;
>
> causes
>
> ERROR: column "test.col" must appear in the GROUP BY clause or be used in
> an aggregate function
> SQL state: 42803
>
> How to fix this ?
> This statement is generated by DbLinq driver and it is difficult to re-qrite
> the driver.
>
> Query looks quite resonable to me and should be accepted by PostgreSQL 8.3
> Beta.
>
> Andrus.
Give a name to the count column and create a subquery:
select *
from (
select count(col) as count_col
from test
) subquery_tmp_name_as_you_wish
order by count_col;
From | Date | Subject | |
---|---|---|---|
Next Message | Tino Wildenhain | 2008-01-15 12:28:01 | Re: insert into ... select ... and column order |
Previous Message | Alvaro Herrera | 2008-01-15 12:16:47 | Re: Segmentation fault with 8.3 FTS ISpell |