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 1nyiu9-00083w-1m for pgsql-sql@arkaria.postgresql.org; Tue, 07 Jun 2022 23:46:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nyiu7-00047Z-RK for pgsql-sql@arkaria.postgresql.org; Tue, 07 Jun 2022 23:46:31 +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 1nyiu7-00047Q-Ik for pgsql-sql@lists.postgresql.org; Tue, 07 Jun 2022 23:46:31 +0000 Received: from mail2-drop-p3.anu.edu.au ([130.56.64.39]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyiu4-0006z5-1E for pgsql-sql@lists.postgresql.org; Tue, 07 Jun 2022 23:46:30 +0000 Received: from mail3-pmx-p4.anu.edu.au (mail3-pmx-p4.anu.edu.au [10.40.70.26]) by mail2-drop-p3.anu.edu.au (8.14.7/8.14.7) with ESMTP id 257NkMmW031649 for ; Wed, 8 Jun 2022 09:46:22 +1000 Received: from mail3-pmx-p4.anu.edu.au (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id 80B1F8059EC6 for ; Wed, 8 Jun 2022 09:46:22 +1000 (AEST) Received: from mail2-smtp-p1.anu.edu.au (snatpool01-3.anu.edu.au [130.56.66.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail3-pmx-p4.anu.edu.au (Postfix) with ESMTPS id 5FAF48059EC5 for ; Wed, 8 Jun 2022 09:46:19 +1000 (AEST) Received: from [150.203.211.229] (littleblue.cecs.anu.edu.au [150.203.211.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: u8909374) by mail2-smtp-p1.anu.edu.au (Postfix) with ESMTPSA id 500D020590E6 for ; Wed, 8 Jun 2022 09:46:18 +1000 (AEST) Message-ID: <6900b4c7-f2d3-267d-4a83-2434b0c6fe07@cs.anu.edu.au> Date: Wed, 8 Jun 2022 09:46:18 +1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: losing my mind about sytnax error in window clause Content-Language: en-US To: pgsql-sql@lists.postgresql.org References: From: Bob Edwards In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-PMX-Version: 6.4.9.2830568, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2022.6.7.233619, AntiVirus-Engine: 5.91.0, AntiVirus-Data: 2022.6.7.5910001 internal X-OriginatorOrg: anu.edu.au X-PerlMx-Spam: Gauge=IIIIIIII, Probability=8%, Report=' HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1400_1499 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, NO_CTA_FOUND 0, NO_CTA_URI_FOUND 0, NO_FUR_HEADER 0, NO_URI_FOUND 0, NO_URI_HTTPS 0, REFERENCES 0, SENDER_NO_AUTH 0, __BODY_NO_MAILTO 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __DQ_NEG_DOMAIN 0, __DQ_NEG_HEUR 0, __DQ_NEG_IP 0, __FORWARDED_MSG 0, __FROM_DOMAIN_NOT_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_REFERENCES 0, __HEADER_ORDER_FROM 0, __HIGHBITS 0, __INVOICE_MULTILINGUAL 0, __IN_REP_TO 0, __MAIL_CHAIN 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_VERSION 0, __MOZILLA_USER_AGENT 0, __NO_HTML_TAG_RAW 0, __PHISH_SPEAR_SUBJ_ALERT 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __SUBJ_REPLY 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_MAILTO 0, __USER_AGENT 0' List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/6/22 09:03, Rein Petersen wrote: > 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 PARITION <> PARTITION - check your spelling. cheers, Bob Edwards. > > >