sql - SP 在条件指定不返回时返回匹配项
问题描述
我的 SP 应该只返回字段 GTid1 <> Gtid2 的记录。但是,当我运行此 sp 然后在 Visual Studio 中加载我的报告时,下面是 SP 中用于提取此报告所需数据的 SQL。它应该返回 LEI1 与 LEI 2 匹配但 GTID1 <> GTID2 的数据
例子 :
GTID1 = G0101 LEI:E12345 GTID2:G0201 LEI:E12345
select distinct
@reportIdLeiDuplicates,
wp1.CrmPartyId,
wp1.GtId,
convert(varchar(20),
hashbytes('SHA1', isnull(wp1.CrmPartyId, '') + isnull(wp1.GtId, '') ),
2),
(select AttributeId from REPORTING.Attribute where Name = 'GT ID'), @WeccoSysId, wp1.GtId,
(select AttributeId from REPORTING.Attribute where Name = 'CRM Party Id'), @WeccoSysId, wp1.CrmPartyId,
(select AttributeId from REPORTING.Attribute where Name = 'Legal Name'), @WeccoSysId, wp1.LegalName,
(select AttributeId from REPORTING.Attribute where Name = 'Business Class'), @WeccoSysId, wp1.BusinessClass,
(select AttributeId from REPORTING.Attribute where Name = 'Relationship Manager Name'), @WeccoSysId, wp1.RmFullName,
(select AttributeId from REPORTING.Attribute where Name = 'PbeName'), @WeccoSysId, wp1.PbeFullName,
(select AttributeId from REPORTING.Attribute where Name = 'Overall Status'), @WeccoSysId, wp1.OverallStatus,
(select AttributeId from REPORTING.Attribute where Name = 'LEI'),
[![enter image description here][1]][1]@WeccoSysId, wp1.Lei,
(select AttributeId from REPORTING.Attribute where Name = 'GT ID'),
@WeccoSysId, wp2.GtId,
(select AttributeId from REPORTING.Attribute where Name = 'CRM Party Id'), @WeccoSysId, wp2.CrmPartyId,
(select AttributeId from REPORTING.Attribute where Name = 'Legal Name'),
@WeccoSysId, wp2.LegalName,
(select AttributeId from REPORTING.Attribute where Name = 'Business
Class'), @WeccoSysId, wp2.BusinessClass,
(select AttributeId from REPORTING.Attribute where Name = 'Relationship
Manager Name'), @WeccoSysId, wp2.RmFullName,
(select AttributeId from REPORTING.Attribute where Name = 'PbeName'),
@WeccoSysId, wp2.PbeFullName,
(select AttributeId from REPORTING.Attribute where Name = 'Overall
Status'), @WeccoSysId, wp2.OverallStatus,
(select AttributeId from REPORTING.Attribute where Name = 'LEI'),
@WeccoSysId, wp2.Lei
from core.WeccoParty wp1
join CORE.WeccoParty wp2 on wp1.Lei = wp2.Lei
where wp1.Lei is not null
and wp1.GtId < wp2.GtId
and wp2.Lei is not null
解决方案
推荐阅读
- javascript - How can I add a variable in place f a constant in javascript
- python - How IIS recognize Chinese character in URL
- intellij-idea - 如何阻止移动目录(和新创建的文件)中的文件在编辑器中自动打开(PyCharm 2020.1)
- r - Convert categorical "other" value to NA in a data frame using dplyr
- javascript - How to add dynamic field types to Angular FormArray?
- java - 如何使用 Bazel 运行 JavaFX 程序?
- android - Android Jetpack 导航控制器 | 获取当前目的地的操作列表
- typescript - 根据在打字稿中作为参数接收的类定义方法返回类型
- amazon-web-services - 如何创建 Cloudfront 控制台警报 Terraform
- ruby-on-rails - 如何将 RoR Active Admin 过滤器按钮文本更改为英文