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 1ubOe9-000JX9-Ot for pgsql-general@arkaria.postgresql.org; Mon, 14 Jul 2025 19:15:29 +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 1ubOe7-00CF52-NJ for pgsql-general@arkaria.postgresql.org; Mon, 14 Jul 2025 19:15:28 +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 1ubOe7-00CF4p-Cm for pgsql-general@lists.postgresql.org; Mon, 14 Jul 2025 19:15:28 +0000 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ubOe5-007hLR-2a for pgsql-general@lists.postgresql.org; Mon, 14 Jul 2025 19:15:27 +0000 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-613a6e39f52so1787756eaf.3 for ; Mon, 14 Jul 2025 12:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752520524; x=1753125324; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bZNuhyxujn7iFfh8SjkGLFSPYRJREj6VE6alvGjbQII=; b=Arcj7fl0NrLAEvavsXxQ/9IiqgYdne3DdVa8NP93HUc3E8RuF96cLtFyfFwowQdIRF oMLZX3kYBCHMhvU7va3dnVfT5qllsdZCY2st4qv4fWQLkgPbBHFE4obEictWdg8xzBIt ldWJ+wYq2ATmJ7G7i9dZ9iWQS78m+1Z+qAtMuvCo3S0C2ZUeR0pjDL3KfyJPcX1515t+ rLyRN2tfYRAgFO1g+d/Q8Lc+57dgZBMz63gSuN1B/HUGi3Tr9rwEXaklcuDwgYW9smGH ksJVC4Q/t9HWw9nfr5SRAonzjjLnboI7lrCVy/mw5JvQbLbL78aMCWxJgQLEDV63FrDW QFeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752520524; x=1753125324; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bZNuhyxujn7iFfh8SjkGLFSPYRJREj6VE6alvGjbQII=; b=knJOLlS5xhuiXuHbwwORA8rw1bsShEeEmbOibxqPId2gQEV3tJ0fHZ6lEpMRbx6CXr P5KANjs8zQX+cVQDOmxOk2mYMW20ZDY4B51I4vZaJNtCJEoZ7Jk9DjEcbZWCCTBjauVz /dCTgakmlp+QqDpTUPhimnLM20K291j9IEw4S1JGCitg2yPbOomYuhL4suEwgDeloL9y H3QjwhTskSLwv25XiHGjrCeTmRpjPDHcsKMPik7+7kJgVKkpS0AMBNJ9OAyoKxzN2Hg9 BSia9gb4TSGQ+pqDwtjb689HykvTHHJ5CxEbE0PxfyEP+VYgXnat8QULQKzybvlbpmQg akLQ== X-Gm-Message-State: AOJu0YzUa2P/rT8JDutXaa/Tj55/vtsjo8AB+AJFS79cXoJEPSDpYBoB voismhqZuQU8mElyZhb9OVq+YBCaTsJ73gKWA/s2Izbocm+WLhRh7NaIrD+xjO+MW8nb8ymVg9b uOMHCbDGIjrqqQ7vHwuGddL6+cbaced4= X-Gm-Gg: ASbGncv+WOxgbt/QwJNSkZXkOyYw1bedHAnuSuyEWbmNbEbzhih4dy3UiDOwjFIH4ap +sn12QRX/t22h++b3Px75nD6aeGGt96vxS2nITz8K+v0UQ9rXz6SkeKoPQrCFaPbNTJqqmXNo+W RZMmQ6fp8hR0BGJs/+nbFChJ27YvKMVnfnERiIp8aZGYeq/2SSXSoNzf5cISFlcUXY/FeQRP7IF UBDCcMGYkk5f3ESH4bYEKr10zcyyYQJavu0oOnqU1otu94fjA== X-Google-Smtp-Source: AGHT+IFL+of8D4oRQVBCq5FqeqT/CoKsB6//ogEXgtAJLJ/U80fuxHi2MAA+cf6+Ip2COzGgkXT0Z5nXQTQfwW4MDLo= X-Received: by 2002:a05:6820:210:b0:613:bfa6:2130 with SMTP id 006d021491bc7-613e6055d58mr9359823eaf.8.1752520523738; Mon, 14 Jul 2025 12:15:23 -0700 (PDT) MIME-Version: 1.0 References: <9c84776d-d938-9fa4-ab1-6ee960ce6e7d@appl-ecosys.com> In-Reply-To: <9c84776d-d938-9fa4-ab1-6ee960ce6e7d@appl-ecosys.com> From: "David G. Johnston" Date: Mon, 14 Jul 2025 12:14:47 -0700 X-Gm-Features: Ac12FXx_9aVoE6WDSjE3Ay8B5qY0qa0uYMKHSSk7b2XC0XdTQNKgp7musk1sxZo Message-ID: Subject: Re: Syntax error needs explanation To: Rich Shepard Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000047724c0639e87b47" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000047724c0639e87b47 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jul 14, 2025 at 12:12=E2=80=AFPM Rich Shepard wrote: > 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 =3D 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? > The error indicates your script file is at least 127 lines long and you are showing like 9...also do you usually name your script files with a .txt extension? David J. --00000000000047724c0639e87b47 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Jul 14, 2025 at 12:12=E2=80=AFPM Rich Shepard <= rshepard@appl-ecosys.com>= ; wrote:
I have the following scr= ipt:

select c.company_nbr, c.company_name, i.industry,
from companies as c, industry as i, enforcement as e
where exists (
=C2=A0 =C2=A0select c.company_nbr, count(e.action_date), sum(e.penalty_amt)=
=C2=A0 =C2=A0from e.enforcement
=C2=A0 =C2=A0where c.company_nbr =3D e.company_nbr
=C2=A0 =C2=A0)
group by industry
order by industry;

When I run it psql reports an error:
psql:companies-with-enforcement-actions.txt:127: ERROR:=C2=A0 syntax error = at or near "company_nbr"
LINE 1: company_nbr |=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0company_name
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^
and I'm not seeing the error. What am I missing?

The error indicates your script file is at l= east 127 lines long and you are showing like 9...also do you usually name y= our script files with a .txt extension?

David J.
=

--00000000000047724c0639e87b47--