Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubOaz-000Iyz-8M for pgsql-general@arkaria.postgresql.org; Mon, 14 Jul 2025 19:12:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ubOax-00C834-BS for pgsql-general@arkaria.postgresql.org; Mon, 14 Jul 2025 19:12:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubOax-00C82p-0N for pgsql-general@lists.postgresql.org; Mon, 14 Jul 2025 19:12:11 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ubOav-007hFK-1D for pgsql-general@lists.postgresql.org; Mon, 14 Jul 2025 19:12:11 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 0C6D12A14D6 for ; Mon, 14 Jul 2025 12:12:07 -0700 (PDT) Date: Mon, 14 Jul 2025 12:12:07 -0700 (PDT) From: Rich Shepard Reply-To: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Syntax error needs explanation Message-ID: <9c84776d-d938-9fa4-ab1-6ee960ce6e7d@appl-ecosys.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I have the following script: select c.company_nbr, c.company_name, i.industry, from companies as c, industry as i, enforcement as e where exists ( select c.company_nbr, count(e.action_date), sum(e.penalty_amt) from e.enforcement where c.company_nbr = e.company_nbr ) group by industry order by industry; When I run it psql reports an error: psql:companies-with-enforcement-actions.txt:127: ERROR: syntax error at or near "company_nbr" LINE 1: company_nbr | company_name ^ and I'm not seeing the error. What am I missing? TIA, Rich