Re: Unique Primary Key Linked to Multiple Accounts

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Anthony Apollis <anthony(dot)apollis(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Unique Primary Key Linked to Multiple Accounts
Date: 2023-11-13 16:47:03
Message-ID: e4fd0ae1-ab0a-4b83-90aa-12ee4e0ebc23@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2023-11-13 16:49:03 Re: Is "WITH RECURSIVE" limited to the first position of CTEs by design?
Previous Message Adrian Klaver 2023-11-13 16:45:24 Re: Unique Primary Key Linked to Multiple Accounts