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 1sTjQl-001rch-1S for pgsql-general@arkaria.postgresql.org; Tue, 16 Jul 2024 14:45:27 +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 1sTjQj-001Juu-1h for pgsql-general@arkaria.postgresql.org; Tue, 16 Jul 2024 14:45:25 +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 1sTjQi-001Jul-4F for pgsql-general@lists.postgresql.org; Tue, 16 Jul 2024 14:45:24 +0000 Received: from fhigh6-smtp.messagingengine.com ([103.168.172.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sTjQe-002QaY-Dw for pgsql-general@lists.postgresql.org; Tue, 16 Jul 2024 14:45:23 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 1D75F114805F; Tue, 16 Jul 2024 10:45:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 16 Jul 2024 10:45:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1721141118; x=1721227518; bh=2jrnhx6cS3DsTrdKiqWYwS8NY9EpaeZC5wAvvdb9QJ4=; b= NIYvJLfXJ6uZLmqkpycpghznoRag/OIrEb0uGNmYkFB0KBpNY57xakFnGprFpfQ/ HX5NUvfbo9LhbA23+dvG1tqPIJCxbbO5xAh1PjqxAym6RgVyNSsM1dtqqzgEl73q 6eg3HEUZDyB8DM/z72V469TJoGKzcNKpUXeZuY6kbhxK87q1uu1+040f5OXCO/NB MYWsJB2F7cVLZsuXFpP6U+l5PuDwHXT3DEYjmmL1nmEVWxTLOSGgS01rTVjT/Fa8 fGSNrxMQV3DEsywsJdI4q6I9/ndb6pFuvzrnx0A5+ZO+fpU8qqa8ZaRnCQ9+CWc/ bJHJ+6n4nEHU9eQvhVXr4Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1721141118; x= 1721227518; bh=2jrnhx6cS3DsTrdKiqWYwS8NY9EpaeZC5wAvvdb9QJ4=; b=a hjyGYzrF1uTxPgjn/m7fwA959Lq3XuEjEtlU0L3GpGyG3K7lDvy04uekwcf6G+5H +pELZbpjRSJdkbg7jrD8mgz6++SVc94rEx/zQr64fVdQFTTNELBONmIZ6iycLR1K Z8zprLJmT9mQMcm8raqgyEfd3Wfq7mqlv/jFga4q02g2Mk6u91SnNe3vI3Vqwqsu pXPi54T4SuntbC9BUek8DvhkY94M9Hux7k/A/K3h43xVGk3ghbhAwkn7jRumlq6t 0PYVfBn2QiabDqheEsY1DZlQybhWxmQc6B9Z/l5/ssuhqwRO34SUHbgSvEDItHme fg5RfB+SmIC+/oJ8KQZPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrgeeggdejkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepffelgeeifefgveduhedthfekuedtffejveegffegjeev tdehgfduieetfeehjeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Jul 2024 10:45:17 -0400 (EDT) Message-ID: <1fd63ee5-a8a3-492e-a38d-82ff21da26b8@aklaver.com> Date: Tue, 16 Jul 2024 07:45:16 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Code does Not Read in FY 2025 Data To: Anthony Apollis , pgsql-general@lists.postgresql.org References: Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/16/24 05:53, Anthony Apollis wrote: > 1. The problem is the code below reads only data up until 2024, > although the table has been updated with latest data that contains > 2025, for some odd reason it is not pulling in or showing data when > filtering for 2025 or even 2024 and later, which should contain all > the latest data. > 2.  SQL: "SET DATEFIRST 7;-- Holding Period Query I don't recognize SET DATEFIRST 7 as Postgres command. What database are you running this on? Have not gone through the below fully, but this: "FY" IS NOT NULL AND "FY" >= 'FY24' and this WEEK_NUMBER."Date" < CURRENT_DATE would seem to be at odds if you want to reach into 2025. > > SELECT > > 3. > > -- Holding Period Query > SELECT >     WEEK_NUMBER."Week Number", >     WM_GH."Calendar day", >     WM_GH."Month/Week", >     WM_GH."Day name", >     WM_GH."Company", >     WM_GH."Material Code", >     WM_GH."Metric", >     WM_GH."Metric Value" > FROM >     ( >         SELECT >             "Calendar day", >             "Month/Week", >             "Day name", >             "Company", >             "Material Code", >             "Metric", >             "Metric Value" >         FROM > > "Prod"."IMETA_Weekly_Metrics_in_Focus_Global_Stock_View_SAP_BW" AS WM_GH >         WHERE >             WM_GH."Metric Focus" LIKE 'Weekly' >             AND WM_GH."Calendar day" <= ( >                 SELECT MAX(WEEK_NUMBER."Date") AS "MAX DATE" >                 FROM ( >                     SELECT >                         "Date", >                         "Week number", >                         COUNT("Date") OVER (PARTITION BY "Week > number" ORDER BY "Week number") AS "Number of days", >                         COUNT("Date") OVER (PARTITION BY "Week > number" ORDER BY "Date") AS "Day number in weeks" >                     FROM ( >                         SELECT DISTINCT >                             "Date", >                             EXTRACT(WEEK FROM WEEK_NUMBER."Date") > AS "Week number" >                         FROM > > "dbo"."IMETA_Calendar_Days_Data_Table_Copy10" AS WEEK_NUMBER >                         WHERE >                             "FY" IS NOT NULL AND "FY" >= 'FY24' >                     ) AS W_MAX >                 ) AS WEEK_NUMBER >                 WHERE >                     WEEK_NUMBER."Date" < CURRENT_DATE >                     AND "Number of days" = "Day number in weeks" >             ) >     ) AS WM_GH > LEFT OUTER JOIN >     ( >         SELECT >             * >         FROM ( >             SELECT >                 "Date", >                 "Week number", >                 COUNT("Date") OVER (PARTITION BY "Week number" > ORDER BY "Week number") AS "Number of days", >                 COUNT("Date") OVER (PARTITION BY "Week number" > ORDER BY "Date") AS "Day number in weeks" >             FROM ( >                 SELECT DISTINCT >                     "Date", >                     EXTRACT(WEEK FROM WEEK_NUMBER."Date") AS "Week > number" >                 FROM >                     "dbo"."IMETA_Calendar_Days_Data_Table_Copy10" > AS WEEK_NUMBER >             ) AS W_MAX >         ) AS WEEK_NUMBER >         WHERE >             WEEK_NUMBER."Date" < CURRENT_DATE >     ) AS WEEK_NUMBER > ON >     WM_GH."Calendar day" = WEEK_NUMBER."Date" > ORDER BY >     WM_GH."Calendar day" DESC; > -- Adrian Klaver adrian.klaver@aklaver.com