Re: joined tables with USING and GROUPBY on the USING() column

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: joined tables with USING and GROUPBY on the USING() column
Date: 2016-09-07 20:00:01
Message-ID: e4101f69-1cef-e961-7ffb-d5ba1c6cbec0@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/7/2016 12:53 PM, Geoff Winkless wrote:
> I'll start by saying that I'm sure I'm missing something obvious...
>
> I have a query that is working fine on all my servers except one. The
> only obvious difference is that the failing one is running 9.5.3,
> while most are running 9.5.4, but since the query works on a 9.5.1 box
> I also have I can't imagine that's the cause.
>
> I can simplify the query (and still retain the error) down to:
>
> SELECT results.token FROM results INNER JOIN tokens USING(token) GROUP BY token;
>
> ERROR: column "results.token" must appear in the GROUP BY clause or be
> used in an aggregate function
>
> All well and good, and I'm happy enough to change the query's GROUP BY
> to include the table name, but it's confusing me how it works OK on
> all servers except one.
>
> Is there some configuration option I'm missing?

the only thing I can think of is that 'group by token' is ambiguous, if
that was group by results.token, it would be specific. yes, I know,
your join conditions using(token) are equivalent to saying on
results.token=tokens.token, so either token should be the same thing...

--
john r pierce, recycling bits in santa cruz

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-09-07 20:01:10 Re: joined tables with USING and GROUPBY on the USING() column
Previous Message Geoff Winkless 2016-09-07 19:53:48 joined tables with USING and GROUPBY on the USING() column