Re: COUNT() with ORDER BY

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: COUNT() with ORDER BY
Date: 2008-01-16 13:47:28
Message-ID: 20080116134728.GB27832@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jan 14, 2008 at 09:02:46PM +0200, Andrus 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.

Sorry? The query is entirely non-sensical. The output will be a single
row telling you the number of non-null elements in the col column. How
can it be ordered?

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
> -- John F Kennedy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2008-01-16 13:48:13 Re: libpq updateable resultset?
Previous Message Csaba Nagy 2008-01-16 13:43:49 Re: varchar sort ordering ignore blanks