简体   繁体   中英

What join columns should I take for ACDOCA and JVSO1 SAP tables?

I have fetched two SAP ERP tables into Azure Synapse: ACDOCA and JVSO1 .

Now I need to join these two tables. And the column EBELN is required to be in join condition, also both tables have around 40% of EBELN empty. Because of these empty values, these two tables produce a lot of data (In Billions).

What I have tried: I have picked one more column EBELP and joined both tables based on these two columns:

WHERE ACDOCA.EBELN = JVSO1.EBELN AND ACDOCA.EBELP = JVSO1.EBELP

But even after this condition, I am getting a lot of data.

What I want:

I want to join these two tables and have less amount of data (Not in Billions). Can you please suggest me more columns in both tables so that I can join both of the tables correctly with lesser amount of data.

Thanks

Joining conditions on acdoca.ebeln=JVSO1.ebeln and acdoca.ebelp=JVSO1.ebelp and on acdoca.ebeln=JVSO1.ebeln will give same result for rows with null values. I repro'd this with sample data.

Input data with null values:

ebeln EBELP
null A
AA AA
null B

在此处输入图像描述

Joining tables based on ebeln fields:

select * from acdoca full outer join JVSO1 on 
acdoca.ebeln=JVSO1.ebeln 

在此处输入图像描述

Joining tables based on ebeln and ebelp fields:

select * from acdoca full outer join JVSO1 on 
acdoca.ebeln=JVSO1.ebeln and acdoca.ebelp=JVSO1.ebelp

在此处输入图像描述

  • Query should be written in such a way whenever ebeln field is null, condition should be on matching ebelp fields JOIN of tables should happen.
select * from acdoca full outer join JVSO1 
on
(acdoca.ebeln is not null and acdoca.ebeln=JVSO1.ebeln) 
or 
(acdoca.ebeln is null and acdoca.ebelp=JVSO1.ebelp)

or

select * from acdoca full outer join JVSO1 on 
(isnull(acdoca.ebeln,acdoca.ebelp) =
isnull(JVSO1.ebeln,JVSO1.ebelp)) 

Even when you add other matching columns, joining conditions should be like above queries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM