Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyiF9-0006M0-9M for pgsql-sql@arkaria.postgresql.org; Tue, 07 Jun 2022 23:04:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nyiF7-0003ay-O4 for pgsql-sql@arkaria.postgresql.org; Tue, 07 Jun 2022 23:04:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyiF7-0003ap-Bb for pgsql-sql@lists.postgresql.org; Tue, 07 Jun 2022 23:04:09 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nyiF1-0006Za-5F for pgsql-sql@lists.postgresql.org; Tue, 07 Jun 2022 23:04:05 +0000 Received: by mail-wm1-x32c.google.com with SMTP id a10so7499574wmj.5 for ; Tue, 07 Jun 2022 16:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=reinpetersen-com.20210112.gappssmtp.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=Ygp9uOpHSsqfIoK5q9NJLPJn8tjHX+3D9tkh5lEsBAw=; b=XqfO9dR6Dxs+LWlPYXW0cuPLFw6IrJRfAtzNLbiw/rCYjko6JX2cfK40MrLl72x56b YaIYpawLWbLdU6iFBR8/DKBYqSc6kImKi3FHM61OmKFC/uejSUKtG4vzLkax50Y53KaR x1MofRLuLjr5FaR3UnoJdfZ96qmqjN8/ezKgnKgK562jRlKwOFbldt/rrwD+Vbb5X9B7 PClGVeTpyXz9wBHMPAE9ebcldjmpuDap9yBe9xnm6NuS0OKmJpKWguSmJgLAWXTswOKV CL9rYId/UaM5i6mUZxMfluGaJl7YN7TPW2yIRAuD86DwHYYH7Z6Fz30YSC9VmtIbztPe gzAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=Ygp9uOpHSsqfIoK5q9NJLPJn8tjHX+3D9tkh5lEsBAw=; b=seg25Kxzfh12erc1p94BBEZKB41bex6eTvAEiX5rjVM3Mn6E9XnIqxoSPhgdsqNMc1 abBOue+/CWJdqC5TspCW4W8AQLuci3hqLOcNW1hdO8t8i3bDCmE6uSX0WIXb9G+JtFkn +Kyx0dj0jg003zHJ6AvbF/N5IMT94y4sx54eb3sauUV0P7xU1oAnj4paHsTB7IQdHaGY 6+dp1+npWT+4mkOn04io+xsE0VdCy0Ox/92YoQmWBrKpdtheJeWrprUCT3sIMW42J3L4 WOOXyGEyJdwFZdctH7l175eDWJac8ePasrjfJEQy4Rlk7FpUMvsn0sBThS4vuxN9tZZJ xI7w== X-Gm-Message-State: AOAM532HpZNcbeCvEYMLI70Fm1Y5wYqkqD20ppd06OXmXGrY4cIYHR41 nKw2ZXV7z5i9oAXINRppr4OLaY6ndU2b7G3a1yUDNXdk9RyiOwJn X-Google-Smtp-Source: ABdhPJxmOGhHjGpZ+RJfeBfCId2359BSsLwt7/lQrHr0Qd9W1IFdXMeqblqg8y2j4FjkkSExYhVnuXTTv8qfSmRFp3Y= X-Received: by 2002:a1c:4454:0:b0:39c:603b:ea19 with SMTP id r81-20020a1c4454000000b0039c603bea19mr1803542wma.48.1654643035981; Tue, 07 Jun 2022 16:03:55 -0700 (PDT) MIME-Version: 1.0 From: Rein Petersen Date: Tue, 7 Jun 2022 18:03:42 -0500 Message-ID: Subject: losing my mind about sytnax error in window clause To: pgsql-sql@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000063da6c05e0e39a4a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000063da6c05e0e39a4a Content-Type: text/plain; charset="UTF-8" Hi Folks, I've been reading the docs over and again, searching exhaustively for examples on the internet to help me here and I'm ready to give up. I have a query using windows function: SELECT last_value ( typechange ) OVER w, pindex, lid, last_value ( modified ) OVER w, last_value ( created ) OVER w, last_value ( modifiedby ) OVER w, last_value ( createby ) OVER w, last_value ( cost ) FILTER ( WHERE cost IS NOT NULL ) OVER w, last_value ( sell ) FILTER ( WHERE sell IS NOT NULL ) OVER w FROM ps._delta_ext WHERE pindex = Ppindex AND ( Plid IS NULL OR lid = Plid ) AND ( Ptimestamp IS NULL OR modified <= Ptimestamp ) GROUP BY lid, pindex WINDOW w AS ( PARITION BY lid, pindex ORDER BY created ); Complains about syntax error in the WINDOW cause (last line) on [PARTITION] BY: /* messages ERROR: syntax error at or near "BY" LINE 16: WINDOW w AS ( PARITION BY locationid, partindex ORDER BY cr... ^ SQL state: 42601 Character: 2724 */ Maybe my error is clear to someone else, could really use helping hand, thanks. Rein --00000000000063da6c05e0e39a4a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Folks,

I've been reading the= docs over and again, searching exhaustively for examples on the internet t= o help me here and I'm ready to give up.

I hav= e a query using windows function:

SELECT
=C2=A0 =C2=A0 last_v= alue ( typechange ) =C2=A0 =C2=A0 =C2=A0OVER w,
=C2=A0 =C2=A0 pin= dex,
=C2=A0 =C2=A0 lid,
=C2=A0 =C2=A0 last_value ( modi= fied ) =C2=A0 OVER w,
=C2=A0 =C2=A0 last_value ( created ) =C2=A0= =C2=A0OVER w,
=C2=A0 =C2=A0 last_value ( modifiedby ) OVER w,
=C2=A0 =C2=A0 last_value ( createby ) =C2=A0 OVER w,
=C2= =A0 =C2=A0 last_value ( cost )= FILTER ( WHERE cost I= S NOT NULL ) OVER w,
=C2=A0 =C2=A0 last_value ( sell ) FILTER ( WHERE sell IS NOT NULL ) OVER w
FROM ps._delta_ext
WHERE pindex =3D Ppindex AND=
=C2=A0 =C2=A0 ( Plid IS NULL OR lid =3D Plid ) AN= D
=C2=A0 =C2=A0 ( Ptimestamp IS NULL OR modified &= lt;=3D Ptimestamp )
GROUP B= Y lid, pindex
WINDOW w AS ( PARITION BY lid, pindex ORDER BY created );
Complains about syntax e= rror in the WINDOW cause (last line) on [PARTITION] BY:
/* messages
ERROR: =C2=A0syntax err= or at or near "BY"
LINE 16: =C2=A0WINDOW w AS ( PARITION BY locationid, partindex ORD= ER BY cr...
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^
SQL state: 42601
Character: 2724
*/

Maybe my error = is clear to someone else, could really use helping hand, thanks.
=
Rein



--00000000000063da6c05e0e39a4a--