Re: field must appear in the GROUP BY clause or be used
От | John Sidney-Woollett |
---|---|
Тема | Re: field must appear in the GROUP BY clause or be used |
Дата | |
Msg-id | 3077.192.168.0.64.1077898411.squirrel@mercury.wardbrook.com обсуждение исходный текст |
Ответ на | field must appear in the GROUP BY clause or be used in an aggregate function? (Bill Moran <wmoran@potentialtech.com>) |
Ответы |
Re: field must appear in the GROUP BY clause or be used
|
Список | pgsql-general |
Bill Moran said: > I've hit an SQL problem that I'm a bit mystified by. I have two different > questions regarding this problem: why? and how do I work around it? > > The following query: > > SELECT GCP.id, > GCP.Name > FROM Gov_Capital_Project GCP, > WHERE TLM.TLI_ID = $2 > group by GCP.id > ORDER BY gcp.name; > > Produces the following error: > > ERROR: column "gcp.name" must appear in the GROUP BY clause or be used in > an aggregate function Since you're not agregating data, can't you use a select distinct instead? SELECT distinct GCP.id, GCP.Name FROM Gov_Capital_Project GCP, {?something missing here?} WHERE TLM.TLI_ID = $2 ORDER BY gcp.name; (BTW, I wasn't clear if the where clause trying to join to another table?) Doesn't answer your original question, but hope it helps anyway. John Sidney-Woollett
В списке pgsql-general по дате отправления: