1.页面数据
2.表格数据
a数据
select ContractID,LOACode,a.LiquidatedDamages, a.CalculationBase, a.CalculationProportion,
a.ForCycle, a.CappingRatio, a.ContractTerms, a.BusinessAnalysis, a.RiskLevel,a.BusinessAdvice
from SCF_LOA_10636465From a where ContractID='806EF17F-8D51-C975-AB71-A574CCC07839'
and LOACode='1063' and Type=1
b数据
select ContractID,LOACode,b.ContractTerms, b.BusinessAnalysis, b.RiskLevel,b.BusinessAdvice
from SCF_LOA_10636465From b where ContractID='806EF17F-8D51-C975-AB71-A574CCC07839'
and LOACode='1063' and Type=2
3.SQL语句写法
select distinct
coalesce(a.ContractID,b.ContractID) as ContractID,
coalesce(a.LOACode,b.LOACode)as ContractID,
coalesce(a.rows,b.rows)as ContractID,
a.LiquidatedDamages, a.CalculationBase, a.CalculationProportion,
a.ForCycle, a.CappingRatio, a.ContractTerms, a.BusinessAnalysis, a.RiskLevel,a.BusinessAdvice,
b.ContractTerms, b.BusinessAnalysis, b.RiskLevel,b.BusinessAdvice
from
(select row_number() OVER ( PARTITION BY ContractID ORDER BY ContractID) as rows,* from SCF_LOA_10636465From where LOACode='1063' and Type=1) a
full join
(select row_number() OVER ( PARTITION BY ContractID ORDER BY ContractID) as rows,* from SCF_LOA_10636465From where LOACode='1063' and Type=2) b
on a.ContractID=b.ContractID and a.rows=b.rows
where coalesce(a.ContractID,b.ContractID)='806EF17F-8D51-C975-AB71-A574CCC07839'