试图加入这四个嵌套的子查询。

时间:2017-10-03 14:50:06

标签: sql-server

(select * 
from (select encounterId as 'EncounterID', dateOfBirth as 'PatientDateOfBirth', SexCodeId as 'PatientSexNameCodeID' from AlphaPatientDemographics ) as a
join (select id as 'PatientSexNameCodeID', label as 'PatientSexNameCodeLabel',symbol as 'PatientSexNameCodeSymbol', system as 'PatientSexNameCodeSystem' from AlphaCode ) as b
on a.PatientSexNameCodeID = b.PatientSexNameCodeID )

(select *
from (select encounterId as 'EncounterID',ethnicityCodeId as 'PatientEthnicityNameCodeID' from AlphaPatientDemographics ) as c
join ( select id as 'PatientEthnicityCodeNameID', label as 'PatientEthnicityNameCodeLabel',symbol as 'PatientEthnicityNameCodeSymbol', system as 'PatientEthnicityNameCodeSystem' from AlphaCode ) as d
on c.PatientEthnicityNameCodeID = d.PatientEthnicityCodeNameID)

(select * 
from (select encounterId as 'EncounterID',raceCodeId as 'PatientRaceNameCodeID' from AlphaPatientDemographics ) as e
join (select id as 'PatientRaceNameCodeID', label as 'PatientRaceNameCodeLabel',symbol as 'PatientRaceNameCodeSymbol', system as 'PatientRaceNameCodeSystem' from AlphaCode ) as f
on e.PatientRaceNameCodeID = f.PatientRaceNameCodeID) 

(select *
from (select encounterId as 'EncounterID',maritalStatusCodeId as 'PatientMaritalStatusNameCodeID' from AlphaPatientDemographics) as g
join (select id as 'PatientMaritalStatusNameCodeID', label as 'PatientMaritalStatusNameCodeLabel',symbol as 'PatientMaritalStatusNameCodeSymbol', system as 'PatientMaritalStatusNameCodeSystem' from AlphaCode ) as h
on g.PatientMaritalStatusNameCodeID = h.PatientMaritalStatusNameCodeID) 

订购 encounterId,PatientDateOfBirth,PatientSexCodeId,PatientSexNameCodelabel,PatientSexNameCodeSymbol,PatientSexNameCodeSystem,PatientEthinicityCodeId,PatientEthnicityNameCodelabel,PatientEthnicityNameCodeSymbol,PatientEthnicityNameCodeSystem,PatientRaceCodeId,PatientRaceNameCodelabel,PatientRaceNameCodeSymbol,PatientRaceNameCodeSystem,PatientMaritalStatusCodeId,PatientMaritalStatusNameCodelabel,PatientMaritalStatusNameCodeSymbol,PatientMaritalNameCodeSystem

尝试加入这四个嵌套子查询。订购 encounterId,PatientDateOfBirth,PatientSexCodeId,PatientSexNameCodelabel,PatientSexNameCodeSymbol,PatientSexNameCodeSystem,PatientEthinicityCodeId,PatientEthnicityNameCodelabel,PatientEthnicityNameCodeSymbol,PatientEthnicityNameCodeSystem,PatientRaceCodeId,PatientRaceNameCodelabel,PatientRaceNameCodeSymbol,PatientRaceNameCodeSystem,PatientMaritalStatusCodeId,PatientMaritalStatusNameCodelabel,PatientMaritalStatusNameCodeSymbol,PatientMaritalNameCodeSystem 有什么想法吗?

0 个答案:

没有答案