inner join 高阶应用

**inner join 高阶应用**斜体样式

  select a.*,b.mapTarget,c.Partnumber,c.LoincNumber,d.* from snomedct3.dbo.sct_concept a
inner join(select row_number()over(partition by referencedComponentId order by mapTarget) as rn, b.referencedComponentId,*   
FROM [loinc2018].[dbo].[loinc_part_to_snomed2017]) b on a.id=b.referencedComponentId --and b.rn=1
inner join (select row_number()over(partition by Partnumber order by LoincNumber) as rn,*      
FROM [loinc2018].[dbo].[LoincPartLink]) as c on b.mapTarget=c.Partnumber --and c.rn=1
inner join (select row_number()over(partition by LOINC_NUM order by LOINC_NUM) as rn,*      
FROM [loinc2018].[dbo].[loinc_cn]) as d on c.LoincNumber=d.LOINC_NUM --and d.rn=1
where c.PartTypeName='COMPONENT'
order by a.id

你可能感兴趣的:(sql)