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 1r2a5f-00HV7X-9A for pgsql-general@arkaria.postgresql.org; Mon, 13 Nov 2023 16:47:11 +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 1r2a5c-00GhZW-Tf for pgsql-general@arkaria.postgresql.org; Mon, 13 Nov 2023 16:47:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r2a5c-00GhZI-J1 for pgsql-general@lists.postgresql.org; Mon, 13 Nov 2023 16:47:08 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r2a5a-005ONe-5t for pgsql-general@lists.postgresql.org; Mon, 13 Nov 2023 16:47:07 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id D1F143200F99; Mon, 13 Nov 2023 11:47:04 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 13 Nov 2023 11:47:05 -0500 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:sender:subject:subject:to:to; s=fm2; t= 1699894024; x=1699980424; bh=v4DSX94fuM6VOWXuicrhnFGH+0/t3oYeu84 5wwelAR0=; b=qPHKoGY9zFx2Hozre24NzgNV8gsG9cB1ac0gkRXFH1o+pBmjZul 5jt9RU2q75FfdXT194pUyi4FaWUEAeDCar/jJOo44vqc+b/3YIa+7xvxA2e1RPFg VIcVfp+SluOyI7TNxAG3PThxmCj5+mcCP9hyOSUl7AEAC3zkE+/b1UfhLqQKNJOf /4U7wO7FlbhhyNGHfK7Tdl5k7yERxnJhFNXAo+JBV4JB1sFNq0Wyxg/5aNfyjLxR P0bina0JM0Jip+2DCwjmYfZlVR9j86h6cFX9c5k5qDA4cmVMh/85ZmBzcPRJLZKN 6Vti5pWcm15GF02zdhDBBbgWeTeEEqksakg== 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:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1699894024; x= 1699980424; bh=v4DSX94fuM6VOWXuicrhnFGH+0/t3oYeu845wwelAR0=; b=T /h+2/o0zb7F9sp99toqFhteFwWNtMUxNOkdtxOH9DicbISnOwY+E478lgg+Ijig5 GcE9frO0DWud6eK9TxJ/o8YeA9AsVUMzahVj+IkFUfdG9QbLiq8OJ8ThOwUMvxVe 8sbxz0Gg5+C165a2acGrPnLr+xxbyoRsce0Mbo/9Q7JmdAXX39j+VTqyC54seJYR IoN2DEzIvdU3WdSfG3qpIpuTzkyaxuEn964B54MC9cfbklSJa2uA/5AuKjSx2m3j 3GCDy9Kq+bhBrrSxufm42e9WOmjZNrHi9qSEQXDAeCWrHhVF4VXmewDcUVZncVR/ JgWqvEoymYzfY28Lpdp7w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeftddgledtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffhvfhfjggtgfesthejredttddvjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeehgfeutefhtdeivdeihefgveeuhffhleekjeehjefg gfelueehjeffvdehkeeufeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 13 Nov 2023 11:47:03 -0500 (EST) Message-ID: Date: Mon, 13 Nov 2023 08:47:03 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Unique Primary Key Linked to Multiple Accounts Content-Language: en-US From: Adrian Klaver To: Anthony Apollis , pgsql-general@lists.postgresql.org References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/13/23 08:45, Adrian Klaver wrote: > On 11/12/23 23:02, Anthony Apollis wrote: >> Please advice. I brought in data from SAP and assigned unique primary >> key to the table: >> > >> >> I joined it with a dimension table. >> >> Joining code >> >> fact."IMETA_ZTRB_MP$F_ZTBR_TA_BW"ASfact >> LEFTJOINdim."IMETA_BRACS_Mapping"ASbracs_map >> ONfact."Account_Number"=bracs_map."GCoA"ANDfact."Expense_Type"=bracs_map."EXPENSE FLAG" >> >> It is joined on the Account numbers, which appears in the table >> multiple times. Problem is the Unique Primary Key is then mapped to >> these Account numbers multiple times. > > This is not a problem it is the nature of the table definitions and the > query. The PK is "ZTBR_TransactionCode", but you are joining on > fact."Account_Number"=bracs_map."GCoA"ANDfact."Expense_Type"=bracs_map."EXPENSE FLAG". Since you indicate that there are multiple account numbers in the table then it is no surprise that the "ZTBR_TransactionCode" is repeated. Aah, that should be '... multiple repeated account numbers in the table ...' > > >> Please advice. >> > -- Adrian Klaver adrian.klaver@aklaver.com