Re: Slightly confused error message

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Markus Schaber <schabi(at)logix-tt(dot)com>
Cc: PostgreSQL SQL List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Slightly confused error message
Date: 2006-04-28 16:07:04
Message-ID: 1612.1146240424@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Markus Schaber <schabi(at)logix-tt(dot)com> writes:
> I just stumbled over a slightly confused error message:

> mydb=# select count(*),coverage_area from myschema.streets except select
> cd as coverage_area from countryref.disks group by streets.coverage_area;
> ERROR: column "streets.coverage_area" must appear in the GROUP BY
> clause or be used in an aggregate function

> As the query looks, streets.coverage_area is actually used in the GROUP BY.

The complaint is 100% accurate; the subquery that it's unhappy about is

select count(*),coverage_area from myschema.streets

which is an aggregating query, but coverage_area is being used outside
an aggregate without having been grouped by.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Schaber 2006-04-28 16:30:08 Re: Slightly confused error message
Previous Message Markus Schaber 2006-04-28 15:59:45 Slightly confused error message