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 1ubYdg-002J3P-Rs for pgsql-general@arkaria.postgresql.org; Tue, 15 Jul 2025 05:55:40 +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 1ubYde-00HFAj-W4 for pgsql-general@arkaria.postgresql.org; Tue, 15 Jul 2025 05:55:39 +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 1ubYde-00HFAU-Hn for pgsql-general@lists.postgresql.org; Tue, 15 Jul 2025 05:55:39 +0000 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ubYdc-007p5o-32 for pgsql-general@lists.postgresql.org; Tue, 15 Jul 2025 05:55:38 +0000 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-61598534619so76093eaf.2 for ; Mon, 14 Jul 2025 22:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752558934; x=1753163734; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iJG80UCO+UWyBIJUEMwOTzBiRW9U3pdpBuIacM1ME3E=; b=OrmE+rXR15eRZLydfInZg5tO9i9UB/Tk9oWvW+PMBHk49s9lwMBdgq6FTvozyop8Sb qwRyUU5NGMvKgD951D2E+MQS6U3Vx9zsTy4ukKyWnLm0pZEL2+gdagCijgqjNOuPhH3k d9+8qP60a9fd17G2d/k9hJJfyKGQHFoxkDfH81d2jzhUSbWmJ/fWovY+TZFQ3rw/+QB/ ToE/8Q7BS1mnkQ/cGa9NiDjIs+sBRavRl7BVlqSVKGVR/w/YnkqsDM4hXrIXjcUt7wn8 hPsQfaxyGUNbMxcIXEcaeXVpdiNcOGIReJpY3qiwruqMbwiO91f7sgTZUSDWdnNzJ15E XZgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752558934; x=1753163734; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iJG80UCO+UWyBIJUEMwOTzBiRW9U3pdpBuIacM1ME3E=; b=vHPLL0yszC2guW9jNMpaU6FPHM5hXcLtbMtLsjuoI11zYkvL+i1ztel029akknGvYX u+IBfUI1PN6Hu2yHc0hXr5bqszXLMqvFIFe0bKRk8BCEjRssmZ661mhJo4A8s/3XHi/y g5db1ZfS+jhLlQFZ2Oo+qr1m+LxdUWr0s/uQEogBYLl9G+iw3N2/+hx2DKTDNgOLj5Vt 1FHNGyNVFc5ATTmccSHdQdj7Vdm/GH9vRhs0hrlTFMRojklBe7jznTLIFb0nTdyebMhV JMJEkfFwMSJgKlXajbccIyeN2pqONVeeNs9sSUlvIZTXsKhDS2Wy42TSDkoNV2BUIokk pNAQ== X-Forwarded-Encrypted: i=1; AJvYcCWJrbnaUS2fvlZ8XVBupCA81snX5jqD2W4RS58pJzLhaektemUg9bnneldEJSgVgbssZfjQtAQGhXqsuRsH@lists.postgresql.org X-Gm-Message-State: AOJu0Yw7erubc7zOpyiq1YwasS3ZB32sK2UXX9HtE9rMEjMgTE2ly5EF 2KRIZIBOEaUgUpFz32ku15FvaN2Ve63uYZH9zA1bw3Cl1UkXT+F1jCNuhVi54s6H7U3+jjiA8c3 6EUR21g+OWRDzpS/oKIor55V76X0h1BI= X-Gm-Gg: ASbGncuI7n38RfLfso0qQKOCWpkNNc0/+om+c3gv+JAOLmuyeG0K3h8CtRXmXIDIu8s NSWRejDXoW/adVUMofb6YYlOzkfg1nWk6yb2eO7gtJQGpS06f81nIRt/b9nwIQPpuVjwGD+8NDL YXZ3roI8Ta2I8sZ4B/z/axizpHMyaKakimLoNt6FRcN8HkU/kfHObNGle6a/oVH8XXF7u/sQ9iz WCqXQ== X-Google-Smtp-Source: AGHT+IGNa7JrXi9Sf30FteQWqAMJseWCEM9NhNdcldPCyh/n0xBgZkEyXpPI3h+ART+o0seRWocjdY757DkBvQtxPgA= X-Received: by 2002:a05:6820:2114:b0:613:dc07:f43f with SMTP id 006d021491bc7-613e5d33050mr10680529eaf.0.1752558934528; Mon, 14 Jul 2025 22:55:34 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6802:5403:b0:5d3:be6e:4554 with HTTP; Mon, 14 Jul 2025 22:55:33 -0700 (PDT) In-Reply-To: References: <9c84776d-d938-9fa4-ab1-6ee960ce6e7d@appl-ecosys.com> <9c62a6d5-14a-802-b869-6386d7e050fb@appl-ecosys.com> From: "David G. Johnston" Date: Mon, 14 Jul 2025 22:55:33 -0700 X-Gm-Features: Ac12FXwDneZUU9YTqoicS9h6h-ZLHWbfMHszfLY-feAPaEQqxzG8QVHr0gIMI1U Message-ID: Subject: Re: Syntax error needs explanation [RESOLVED] To: Laurenz Albe Cc: Rich Shepard , "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000bd9b1d0639f16c7c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000bd9b1d0639f16c7c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, July 14, 2025, Laurenz Albe wrote: > On Mon, 2025-07-14 at 12:19 -0700, Rich Shepard wrote: > > On Mon, 14 Jul 2025, David G. Johnston wrote: > > > > > The error indicates your script file is at least 127 lines long and y= ou > > > are showing like 9...also do you usually name your script files with = a > > > .txt extension? > > > > Agh! No the filename extension is .sql. But I was using the \o psql > option > > to write script output to files and mistyped the script name. > > > > Mea culpa! > > Apart from that, the subquery seems to be missing a GROUP BY clause. > Well, it=E2=80=99s more that an exists subquery with an aggregate generally= doesn=E2=80=99t make sense (it would need to include a having clause at minimum)=E2=80=A6it= =E2=80=99s not missing a group by clause, it has aggregates it doesn=E2=80=99t need (they = belong in they belong in the main query where the group clause exists without aggregates to justify its existence. David J. --000000000000bd9b1d0639f16c7c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, July 14, 2025, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
On Mon, 2025-07-14 at 12:19 -0700, Rich Shepard wrote:
> On Mon, 14 Jul 2025, David G. Johnston wrote:
>
> > The error indicates your script file is at least 127 lines long a= nd you
> > are showing like 9...also do you usually name your script files w= ith a
> > .txt extension?
>
> Agh! No the filename extension is .sql. But I was using the \o psql op= tion
> to write script output to files and mistyped the script name.
>
> Mea culpa!

Apart from that, the subquery seems to be missing a GROUP BY clause.

Well, it=E2=80=99s more that an exists sub= query with an aggregate generally doesn=E2=80=99t make sense (it would need= to include a having clause at minimum)=E2=80=A6it=E2=80=99s not missing a = group by clause, it has aggregates it doesn=E2=80=99t need (they belong in = they belong in the main query where the group clause exists without aggrega= tes to justify its existence.

David J.
<= br>
--000000000000bd9b1d0639f16c7c--