SQL 大师,
我不明白这个查询的一部分。在选择语句中,有一些看起来像独立的“选择语句”,几乎就像一个函数。此代码是供应商编写的 Blackbaud CRM。正如您在 from 子句中看到的那样,作为独立代码,它们将信息带入数据集中的代码中没有连接。最后一个奇怪的项目是,在别名为 Spouse_id 的列中,列 SPOUSE.RECIPROCALCONSTITUENTID 甚至不存在于所引用的表中。任何 BBCRM 的人都可以解释这一点吗?
谢谢
select
CONSTITUENT.ID,
CONSTITUENT.ISORGANIZATION,
CONSTITUENT.KEYNAME,
CONSTITUENT.FIRSTNAME,
CONSTITUENT.MIDDLENAME,
CONSTITUENT.MAIDENNAME,
CONSTITUENT.NICKNAME,
(select SPOUSE.RECIPROCALCONSTITUENTID
from dbo.RELATIONSHIP as SPOUSE
where SPOUSE.RELATIONSHIPCONSTITUENTID = CONSTITUENT.ID
and SPOUSE.ISSPOUSE = 1) as [SPOUSE_ID],
(select MARITALSTATUSCODE.DESCRIPTION
from dbo.MARITALSTATUSCODE
where MARITALSTATUSCODE.ID = CONSTITUENT.MARITALSTATUSCODEID) as [MARITALSTATUSCODEID_TRANSLATION]
From
dbo.constituent
left join
dbo.ORGANIZATIONDATA on ORGANIZATIONDATA.ID = CONSTITUENT.ID
where
(CONSTITUENT.ISCONSTITUENT = 1)