简体   繁体   English

SQL/SAS 许多重复记录与 JOIN

[英]SQL/SAS many repeat records with JOIN

I have two tables, I would like to combine them so that each ISIN item with transaction date adds the appropriate value from the second table.我有两个表,我想将它们合并,以便每个带有交易日期的 ISIN 项目添加第二个表中的适当值。 However, as in the picture, it shows me the results where the same value is added to each item, I would like them to be non-repeatable.然而,如图所示,它向我展示了为每个项目添加相同值的结果,我希望它们是不可重复的。 How to connect or fix this error.如何连接或修复此错误。

DBMS: SAS数据库管理系统:SAS 在此处输入图像描述

PROC SQL;
create table Instrumenty_2 as
select 
b.WBIL_BRUTTO_PLN
,b.WYCENA_UJE_PLN
,b.KOD_ISIN 
from bmd.PAP_WART_SPR_&thismonth as b
;
quit;
PROC SQL;
create table Instrumenty_4 as
select 
ISIN_CODE
,TRADE_DATE
,SETTLEMENT_DATE
,MATURITY_DATE
,QUANTITY
,GROSS_AMOUNT
from kondor.k_papiery as a
left join Instrumenty_2 as b
on b.KOD_ISIN = a.ISIN_CODE
where DATA_DANYCH EQ &gv_date.
and TYPE_OF_INSTR_SHORT_NAME = "OBLIGACJE" 
and CPTY_SHORT_NAME = "BAN1"


;
quit;

At least one of your table has several entries of the variable you use to join.至少你的一个表有几个你用来加入的变量条目。 SAS acts then in the way you observe. SAS 然后按照你观察的方式行动。 What you could do is using distinct to prevent double rows, however I think this will not solve your problem.你可以做的是使用 distinct 来防止双行,但我认为这不会解决你的问题。 What you could do is try to join using additional columns or add some conditions on both tables.您可以做的是尝试使用其他列进行连接或在两个表上添加一些条件。 But without knowing the data, at least with some example, is offering help somewhat difficult.但是在不知道数据的情况下,至少在一些例子中,提供帮助有些困难。

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

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