hubert depesz lubaczewski <depesz(at)depesz(dot)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?
regards, tom lane