Skip site navigation (1) Skip section navigation (2)

Re: sql

From: Mike Rylander <mrylander(at)gmail(dot)com>
To: akopciuch(at)bddf(dot)ca
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: sql
Date: 2004-10-25 13:05:39
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Mon, 25 Oct 2004 05:44:06 -0600, Andrew J. Kopciuch
<akopciuch(at)bddf(dot)ca> wrote:
> On Monday 25 October 2004 05:20, Mike Rylander wrote:
> You can not have have expressions (columns etc.) in the SELECT list that are
> either not in a GROUP BY clause, or used in an aggregate function when you
> use GROUP BY in the statement.  By saying SELECT *, means you would have to
> GROUP BY gc, co, data, ora ...

Doh!  Of course.   Should have had coffee before writing that ;)

> That isn't going to do what he wants.  And the SQL you stated should give you
> an error:
> ERROR:  column "" must appear in the GROUP BY clause or be used in an
> aggregate function
> What he wants to do is use DISTINCT ON:
> SELECT DISTINCT ON (gc) gc, co, data, ora FROM temp50 ORDER BY gc, ora DESC;
> Andy

In response to

  • Re: sql at 2004-10-25 11:44:06 from Andrew J. Kopciuch

pgsql-sql by date

Next:From: Bruno Wolff IIIDate: 2004-10-25 16:32:50
Subject: Re: now() + integer, not rounded to whole day
Previous:From: Andrew J. KopciuchDate: 2004-10-25 11:44:06
Subject: Re: sql

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group