Re: unhelpful error message - Mailing list pgsql-bugs

From hubert depesz lubaczewski
Subject Re: unhelpful error message
Date
Msg-id 20090618140659.GB5113@depesz.com
Whole thread Raw
In response to Re: unhelpful error message  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Thu, Jun 18, 2009 at 10:03:21AM -0400, Tom Lane wrote:
> hubert depesz lubaczewski <depesz@depesz.com> writes:
> > # create table sold_products (items int4, product_id int4);
> > # create table products (id int4, codename text);
> > # select sp.count, p.codename from sold_products sp join products p on sp.product_id = p.id;
>
> > shown error:
> > ERROR:  column "p.codename" must appear in the GROUP BY clause or be used in an aggregate function
> > LINE 1: select sp.count, p.codename from sold_products sp join produ...
> >                          ^
>
> Per the fine manual, sp.count is another way of writing count(sp).
> Does it make more sense now?

I know why it works that way. But it took me while to figure it out, and
the select sp.count from table sp, seems to be rather hacky thing, not
really well known, and of no big use.

Best regards,

depesz

--
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: unhelpful error message
Next
From: "Kevin Grittner"
Date:
Subject: Re: unhelpful error message