当与外连接相关时,如何从表中选择列的子集?
select a.cust_xref_id, a.est_hour, a.phone_nbr as number, a.credit_calls, a.credit_rpcs, b.sdp_calls
from #temp0 a
full outer join #temp2 b
on a.cust_xref_id = b.sdp_cust_xref_id
and a.est_hour = b.sdp_hour
and a.phone_nbr = b.sdp_phone
当数据在两个表中都不存在时,有没有办法从表 b 获取有关 sdp_cust_xref_id、sdp_hour 和 sdp_phone 的数据通过加入?如果 b.sdp_calls 确实存在,则列值为空。
select a.cust_xref_id, a.est_hour, a.phone_nbr as number, a.credit_calls, a.credit_rpcs, b.sdp_calls
from #temp0 a
full outer join #temp2 b
on a.cust_xref_id = b.sdp_cust_xref_id
and a.est_hour = b.sdp_hour
and a.phone_nbr = b.sdp_phone
Is there a way to get the data from table b with regard to sdp_cust_xref_id
, sdp_hour
, and sdp_phone
when the data does not exist in both tables via the join? If b.sdp_calls does exist, the column values are null.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我又读了几遍,我想我知道你想要什么。试试这个。如果表 b 中的值在 a 中为
NULL
,它将为您提供表 b 中的值:I read it a few more times and I think I know what you want. Try this. It will give you the values from table b if they are
NULL
in a: