X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2387A475CC7 for ; Fri, 21 Feb 2003 13:04:35 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 27727-08 for ; Fri, 21 Feb 2003 13:04:24 -0500 (EST) Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) by postgresql.org (Postfix) with ESMTP id ECFB04758DC for ; Fri, 21 Feb 2003 12:58:19 -0500 (EST) Received: from wocker (wocker.unixathome.org [192.168.0.99]) by bast.unixathome.org (Postfix) with ESMTP id EB5533F52 for ; Fri, 21 Feb 2003 12:58:51 -0500 (EST) From: "Dan Langille" To: pgsql-sql@postgresql.org Date: Fri, 21 Feb 2003 13:01:14 -0500 MIME-Version: 1.0 Subject: 7.3 "group by" issue Message-ID: <3E56231A.22301.1E69F0EA@localhost> X-mailer: Pegasus Mail for Windows (v4.02a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/481 X-Sequence-Number: 11879 Hi folks, This query: SELECT element_id as wle_element_id, COUNT(watch_list_id) FROM watch_list JOIN watch_list_element ON watch_list.id = watch_list_element.watch_list_id AND watch_list.user_id = 1 GROUP BY watch_list_element.element_id gives this error: ERROR: Attribute unnamed_join.element_id must be GROUPed or used in an aggregate function Note that in the select the table name is not mentioned but it is in the GROUP BY. To solve the problem, you either have to name the table in both locations or not name it in either location. Why? -- Dan Langille : http://www.langille.org/