X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7BBADD1D316 for ; Sat, 3 Jan 2004 01:44:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 85743-03 for ; Fri, 2 Jan 2004 21:43:30 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id F1E52D1DF23 for ; Fri, 2 Jan 2004 20:47:43 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id i030ln19017380; Fri, 2 Jan 2004 19:47:49 -0500 (EST) To: Samuel Tardieu Cc: pgsql-sql@postgresql.org Subject: Re: Ambiguous error message In-reply-to: <87smiy1ej9.fsf@inf.enst.fr> References: <87smiy1ej9.fsf@inf.enst.fr> Comments: In-reply-to Samuel Tardieu message dated "Fri, 02 Jan 2004 17:49:46 +0100" Date: Fri, 02 Jan 2004 19:47:48 -0500 Message-ID: <17379.1073090868@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/5 X-Sequence-Number: 16398 Samuel Tardieu writes: > In PostgreSQL 7.4, the following select: > select texten, total > from (select protocolid, count(*) as total) from ips where catid=1 > group by protocolid order by protocolid) as c > inner join protocols using (protocolid); > gives the error message: > ERROR: subquery in FROM must have an alias > HINT: For example, FROM (SELECT ...) [AS] foo. > Why isn't the "as c" considered as an alias? It's complaining about this part: from (select protocolid, count(*) as total) from ips where ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It hasn't gotten as far as noticing your mismatched parentheses and two top-level FROM keywords yet ;-). It would probably be helpful if this message included a cursor location... regards, tom lane