pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Anthony Apollis <anthony.apollis@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Unique Primary Key Linked to Multiple Accounts
Date: Mon, 13 Nov 2023 08:45:24 -0800
Message-ID: <f3234005-01aa-4a0f-9caa-c002f0e46c91@aklaver.com> (raw)
In-Reply-To: <CAJyMCYK2rpd2AH+V6reQRtfprLCEzLzQsPBdOrC8RXVrzLH3wg@mail.gmail.com>
References: <CAJyMCYK2rpd2AH+V6reQRtfprLCEzLzQsPBdOrC8RXVrzLH3wg@mail.gmail.com>

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






view thread (7+ messages)  latest in thread

Message-ID: <f3234005-01aa-4a0f-9caa-c002f0e46c91@aklaver.com>
Permalink:  ../f3234005-01aa-4a0f-9caa-c002f0e46c91@aklaver.com/
Also on:    postgresql.org/message-id/f3234005-01aa-4a0f-9caa-c002f0e46c91@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, anthony.apollis@gmail.com
  Subject: Re: Unique Primary Key Linked to Multiple Accounts
  In-Reply-To: <f3234005-01aa-4a0f-9caa-c002f0e46c91@aklaver.com>
  References: <CAJyMCYK2rpd2AH+V6reQRtfprLCEzLzQsPBdOrC8RXVrzLH3wg@mail.gmail.com> <f3234005-01aa-4a0f-9caa-c002f0e46c91@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox