简体   繁体   English

我应该为 ACDOCA 和 JVSO1 SAP 表采用哪些连接列?

[英]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 .我已将两个 SAP ERP 表提取到 Azure Synapse 中: ACDOCAJVSO1

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.并且列EBELN需要处于连接状态,而且两个表都有大约 40% 的EBELN空的。 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:我尝试了什么:我又选择了一列EBELP并根据这两列加入了两个表:

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. on acdoca.ebeln=JVSO1.ebeln and acdoca.ebelp=JVSO1.ebelp on acdoca.ebeln=JVSO1.ebeln连接条件将为具有 null 值的行提供相同的结果。 I repro'd this with sample data.我用示例数据重现了这一点。

Input data with null values:具有 null 个值的输入数据

ebeln埃伯恩 EBELP EBELP
null null A A
AA AA AA AA
null null B

在此处输入图像描述

Joining tables based on ebeln fields:基于 ebeln 字段连接表:

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

在此处输入图像描述

Joining tables based on ebeln and ebelp fields:基于 ebeln 和 ebelp 字段连接表:

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.只要ebeln字段为 null,就应该以这种方式编写查询,条件应该是匹配的ebelp字段JOIN 表应该发生。
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.即使您添加其他匹配列,加入条件也应该像上面的查询一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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