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 1r2a4C-00HV20-7T for pgsql-general@arkaria.postgresql.org; Mon, 13 Nov 2023 16:45: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 1r2a4A-00Gc47-IJ for pgsql-general@arkaria.postgresql.org; Mon, 13 Nov 2023 16:45:38 +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 1r2a48-00Gc3y-Nn for pgsql-general@lists.postgresql.org; Mon, 13 Nov 2023 16:45:38 +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 1r2a41-005OMa-S4 for pgsql-general@lists.postgresql.org; Mon, 13 Nov 2023 16:45:35 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 0BFCD3200F3B; Mon, 13 Nov 2023 11:45:27 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 13 Nov 2023 11:45:28 -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= 1699893927; x=1699980327; bh=Wf02dsuymrPSHWpVRjyJ2bd8PgY50g3fSdd cP59xbWk=; b=fxWF2h98QZ+ucE/RaDARlSeEx4e/WOICak6vHWZZCglRVmefqNB xZ4tx9IfvccBYQg5RMnqE03y/fMHvEdKKA4nmnp88Kw9R5wDh5qZ+THi4njU8mI3 TxcJnoEs1h0dPvcC1aa98P2WQeayCdqaZVJQVRAOYikLSbZ95tip25Qq/UESa2JL pkEylPVMMYuBbdKyDFvePGlOu1V8MyaKZLSd6zdyNbsAn/R4a//HHzKvXOjyqknw Zcq+6MeDx7UEidELiE0RBoG9LbQ/q7l7p6+aX7/1dIcnjAqwjuZHmkRXip+IFbbI uyTZ/X0UTeNWgSePUoAqntGGngLmlRM2HAA== 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=1699893927; x= 1699980327; bh=Wf02dsuymrPSHWpVRjyJ2bd8PgY50g3fSddcP59xbWk=; b=D 62lWYblpzgBREtpZ01gdIBhvVke/jSi0Q1eJ4uBg92+CoVdqYNsOPW/Mitvdv9z9 p+GlcYbgAKbnmAVw7zItKjkGRnJFZwub70yB3HqfgMK+fnn6SBYFTgoZwZlk914g IIsEJTlvC3RdeOtskvXC0UYcxsOwE7l1z9fPDBFeGh0i6LlVFuq9F/Qlb2fPUln7 tM3BKbGowUJNdwHsBlQ56xwpV84HenRT22QsdHuD55OZant7opSo6DyrX4LJaieK KYG2ff7FcXaBTO7mpGu0CW7etEFO+7QIWm8MXH9fm1j9Xk795I5sMn4e2fa3XDSC y3yT2MRKirrn/boB3TMBg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeftddgledtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthejredttddvjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeeivdfhieehheegueeileejieettdejhedugeefleek vdelkeehtdfgiefffeekudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 13 Nov 2023 11:45:26 -0500 (EST) Message-ID: Date: Mon, 13 Nov 2023 08:45:24 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Unique Primary Key Linked to Multiple Accounts 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: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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. > Please advice. > -- Adrian Klaver adrian.klaver@aklaver.com