Skip to Content
-2
Jul 05, 2018 at 07:31 PM

Need help in sql statement to avoid duplicates

77 Views

Hello,

Need help in table function logic.

In the TF, acc documents with amounts are available(BSEG). Need to join with sales data vbrp(only VBELN) to get the item details.

When we do left outer join or inner join getting duplicate entries with duplicate amounts. We want to have the item entries but not the fi amounts duplicates.

Need help with

Eg: BSEG

BELNR BUKRS GJAHR BUZEI DMBTR

doc1 buk1 2018 1 9,999

doc1 buk1 2018 2 8,888

sales entries

VBELN AUBEL AUPOS

doc1 66666 10

doc1 66666 20

when using left outer join, it is resulting as

BELNR BUKRS GJAHR BUZEI DMBTR AUBEL AUPOS

doc1 buk1 2018 1 9,999 6666 10

doc1 buk1 2018 1 9,999 6666 20

doc1 buk1 2018 2 8,888 6666 10

doc1 buk1 2018 2 8,888 6666 20

we need output as below with DMBTR having amt only once without duplicates

BELNR BUKRS GJAHR BUZEI DMBTR AUBEL AUPOS

doc1 buk1 2018 1 9,999 6666 10

doc1 buk1 2018 1 0 6666 20

doc1 buk1 2018 2 8,888 6666 10

doc1 buk1 2018 2 0 6666 20

Tried with Rank etc without success. Please help with the select query in table function or in calc view.

Thanks,

Prasad