三个变量上两个 table 的内部连接
Inner join of two table on three variable
我想在 table a 和另一个包含 2 列的 table b 之间进行内部联接,我希望 table a 中的 key_service 相等到 table b 的变量 key_service 的关键服务元素,也等于 table b 的变量 parent_key_service 的元素。
我通过在我的 table 之间做两个内部连接并做一个联合来解决这个问题,但我想直接做,这可能吗?谢谢
proc sql;
create table ca_m_service as
select a.month_key, a.service_key, a.tot_revenue, a.TOT_REVENUE_DISCNT, a.euser_key, b.*
from fr_dme.M_service_rev_by_euser_f as a
inner join code_remise_ass as b
on a.service_key = b.service_key
inner join code_remise_ass as c
on a.service_key = c.parent_service_key
where a.month_key between 201504 and 201509;
quit;
您可以在连接子句中使用 AND 逻辑语句。
create table ca_m_service as
select a.month_key
, a.service_key
, a.tot_revenue
, a.TOT_REVENUE_DISCNT
, a.euser_key
, b.*
from fr_dme.M_service_rev_by_euser_f as a
inner join
code_remise_ass as b
on a.service_key = b.service_key
and a.service_key = b.parent_service_key
where a.month_key between 201504 and 201509 ;
我想在 table a 和另一个包含 2 列的 table b 之间进行内部联接,我希望 table a 中的 key_service 相等到 table b 的变量 key_service 的关键服务元素,也等于 table b 的变量 parent_key_service 的元素。 我通过在我的 table 之间做两个内部连接并做一个联合来解决这个问题,但我想直接做,这可能吗?谢谢
proc sql;
create table ca_m_service as
select a.month_key, a.service_key, a.tot_revenue, a.TOT_REVENUE_DISCNT, a.euser_key, b.*
from fr_dme.M_service_rev_by_euser_f as a
inner join code_remise_ass as b
on a.service_key = b.service_key
inner join code_remise_ass as c
on a.service_key = c.parent_service_key
where a.month_key between 201504 and 201509;
quit;
您可以在连接子句中使用 AND 逻辑语句。
create table ca_m_service as
select a.month_key
, a.service_key
, a.tot_revenue
, a.TOT_REVENUE_DISCNT
, a.euser_key
, b.*
from fr_dme.M_service_rev_by_euser_f as a
inner join
code_remise_ass as b
on a.service_key = b.service_key
and a.service_key = b.parent_service_key
where a.month_key between 201504 and 201509 ;