From: | "Gerhard Dieringer" <DieringG(at)eba-haus(dot)de> |
---|---|
To: | "<Antti Linno" <alligator(at)all(dot)ee> |
Cc: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Antw: GROUP by |
Date: | 2000-07-05 12:11:22 |
Message-ID: | s963420e.005@kopo001 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Antti Linno <alligator(at)all(dot)ee> wrote:
> I have table job, and I want to select data from it, grouping by
> workgroups. When I use
> select id,name from job where workgroup='top leaders' AND ... group by
> workgroup;
> When I want to group, I get
> ERROR: Illegal use of aggregates or non-group column in target list
> I'm confused, why does query work only with sum,min etc. alone in
> select.
>
> Antti
You can use GROUP BY only in conjunction with aggregat functions. Then you have to gruop by all attributes in the target list, that are not aggregated.
Example:
select id,name, workgroup, count(*)
from job
where workgroup='top leaders' AND ...
group by id,name,workgroup;
-------------
Gerhard
From | Date | Subject | |
---|---|---|---|
Next Message | tjk@tksoft.com | 2000-07-05 12:15:12 | Re: Group BY ...(cont.) |
Previous Message | Antti Linno | 2000-07-05 12:01:44 | Group BY ...(cont.) |