Thread: GROUP by
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
On Wed, 5 Jul 2000, Antti Linno 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; this query is probably incorrect: because of the "where workgroup=" the "group by workgroup" can't do anything. bye, Jerome ALET - alet@unice.fr - http://cortex.unice.fr/~jerome Faculte de Medecine de Nice - http://noe.unice.fr - Tel: 04 93 37 76 30 28 Avenue de Valombrose - 06107 NICE Cedex 2 - FRANCE
You can use group by without having an aggregate operator but if you use an aggregate you have to put the group by column int the select. By the way what is after the AND? I hope it is not another workgroup condition because it doesn't have much sense, I think. If you are filtering different types of workgroup you should use OR. Jesus. On Wed, 5 Jul 2000, Antti Linno 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 > >