weird GROUP BY error

From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: pgsql-general(at)postgresql(dot)org
Subject: weird GROUP BY error
Date: 2006-03-30 00:07:49
Message-ID: Pine.LNX.4.44.0603300344240.22475-100000@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi All!

I experienced the strange error when running a simple query.

1) I have the following tables :
wsdb=# \d slit_data
Table "public.slit_data"
Column | Type | Modifiers
--------+------------------+-----------
chip | smallint |
tile | smallint |
slit | smallint |
id | integer |
cx | double precision |
....

wsdb=# \d gems_spec
Table "public.gems_spec"
Column | Type | Modifiers
-----------+-----------------------+-----------
tile | smallint |
chip | smallint |
id | integer |
priority | smallint |
....

2) When I run the query like this
wsdb# SELECT id,slit,tile,chip FROM slit_data LEFT JOIN gems_spec
USING(id,tile,chip) WHERE cx>0.5 ORDER BY priority,id;

it runs smoothly, but when I run the same query with aggregate, I get the
error:

wsdb=# SELECT count(*) FROM slit_data LEFT JOIN gems_spec
USING(id,tile,chip) WHERE cx>0.5 ORDER BY priority,id;

ERROR: column "gems_spec.priority" must appear in the GROUP BY clause or be
used in an aggregate function

Is that normal? I really do not see the reason for the error. I even don't
use the "GROUP BY" clause. Am I wrong ?

(I'm using PG 8.1.3)

Thanks in advance for any advices.

Regards,
Sergey

*****************************************************
Sergey E. Koposov
Max Planck Institute for Astronomy/Sternberg Astronomical Institute
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math(at)sai(dot)msu(dot)ru

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris 2006-03-30 00:53:59 Re: weird GROUP BY error
Previous Message Harvey, Allan AC 2006-03-29 23:45:20 Is this possible.