仅从以下条件获取结果

时间:2015-10-20 08:53:34

标签: sql sql-server

我有一个查询,并希望只获得从下面的select语句中显示的结果,但在这里我得到两个结果,请你帮我一样

Select distinct b.KeyInstn,DateEnded,
BRxB3AOCIOptOutElection as '49370', BRxB3CommonEqTier1CapBefAdj as '48830',(BRxB3GoodwillNetofAssocDTLs+BRxB3IntangbleNetofAssocDTLs) as '48833', (BRxB3AOCIUnrlzdGainonAFSSec+BRxB3UnrlzdLossonAFSPrefStock+BRxB3AOCINetGainCashFlowHed+BRxB3AOCIBenefitPostretirement+BRxB3AOCINetGainonHTMSec) as '88252',(BRxB3NonSigInvest10Threshold+BRxB3AllOthDedCommEqTier1Cap+BRxB3OthDedRelatedtoFVLiab+BRxB3TotalAdjustCommEqT1Cap) as '48837', BRxB3CommonEquityTier1Capital as '47306', BRxB3AddTier1CapSurplus as '88253', (BRxB3NonQualifyCapInstrT1Cap+BRxB3Tier1MinorityInterest) as '88254', BRxB3AddTier1CapDeduction as '48840', BRxB3Tier1Capital as '113',(BRxB3T2CapInstrumentSurplus+BRxB3NonQualifyCapInstrT2Cap+BRxB3CapMinorIntExcFrmT1Cap) as '48843' , BRxB3ALLLInclinTier2Capital as '48844', BRxB3EligbleCrResInclinT2Cap as '88255' , (BRxB3UnrealGainonAFSPrefStock-BRxB3Tier2CapitalDeductions) as '48846', BRxB3Tier2Capital as '48841', BRxB3TotalCapital as '479',BRxB3CommonEqTier1CapRatio as '88260', BRxB3Tier1CapitalRatio as '88261', BRxB3TotalCapitalRatio as '88262', BRxB3TotalRiskWeightedAssets as '88263', BRxB3CommEqT1CapRatioAdvApp as '88264', BRxB3Tier1CapRatioAdvAppr as '88265',BRxB3TotalCapitalRatioAdvApp as '88266', BRxB3TotRiskWeighAssetAdvApp as '88271', BRxSupplementaryLeverageRatio as '88238', BRxB3Tier1LeverageRatio as '147', BRxTier1CommRiskRatio as '47307', BRxTierRiskbasedRatioAll as '478', BRxTotRiskbasedRatioAll as '95',BRxRiskWeightedAssets as '44851'
--BRxB3AOCIOptOutElection as '49370'+'$'+ BRxB3CommonEqTier1CapBefAdj as '48830'+'$'+(BRxB3GoodwillNetofAssocDTLs+BRxB3IntangbleNetofAssocDTLs) as '48833'+'$'+ (BRxB3AOCIUnrlzdGainonAFSSec+BRxB3UnrlzdLossonAFSPrefStock+BRxB3AOCINetGainCashFlowHed+BRxB3AOCIBenefitPostretirement+BRxB3AOCINetGainonHTMSec) as '88252'+'$'+(BRxB3NonSigInvest10Threshold+BRxB3AllOthDedCommEqTier1Cap+BRxB3OthDedRelatedtoFVLiab+BRxB3TotalAdjustCommEqT1Cap) as '48837'+'$'+ BRxB3CommonEquityTier1Capital as '47306'+'$'+ BRxB3AddTier1CapSurplus as '88253'+'$'+ (BRxB3NonQualifyCapInstrT1Cap+BRxB3Tier1MinorityInterest) as '88254'+'$'+ BRxB3AddTier1CapDeduction as '48840'+'$'+ BRxB3Tier1Capital as '113'+'$'+(BRxB3T2CapInstrumentSurplus+BRxB3NonQualifyCapInstrT2Cap+BRxB3CapMinorIntExcFrmT1Cap) as '48843' +'$'+ BRxB3ALLLInclinTier2Capital as '48844'+'$'+ BRxB3EligbleCrResInclinT2Cap as '88255' +'$'+ (BRxB3UnrealGainonAFSPrefStock-BRxB3Tier2CapitalDeductions) as '48846'+'$'+ BRxB3Tier2Capital as '48841'+'$'+ BRxB3TotalCapital as '479'+'$'+BRxB3CommonEqTier1CapRatio as '88260'+'$'+ BRxB3Tier1CapitalRatio as '88261'+'$'+ BRxB3TotalCapitalRatio as '88262'+'$'+ BRxB3TotalRiskWeightedAssets as '88263'+'$'+ BRxB3CommEqT1CapRatioAdvApp as '88264'+'$'+ BRxB3Tier1CapRatioAdvAppr as '88265'+'$'+BRxB3TotalCapitalRatioAdvApp as '88266'+'$'+ BRxB3TotRiskWeighAssetAdvApp as '88271'+'$'+ BRxSupplementaryLeverageRatio as '88238'+'$'+ BRxB3Tier1LeverageRatio as '147'+'$'+ BRxTier1CommRiskRatio as '47307'+'$'+ BRxTierRiskbasedRatioAll as '478'+'$'+ BRxTotRiskbasedRatioAll as '95'+'$'+BRxRiskWeightedAssets as '44851' as TEststring

--BRxB3AOCIOptOutElection , BRxB3CommonEqTier1CapBefAdj 
into #temp From SNL..BankRegFinlEOP a
JOIN SNL..BankRegEntity b  ON a.KeyBankRegEntity = b.KeyBankRegEntity
JOIN SNL..BankRegFinlEOPI i  ON a.KeyBankRegFinlEOP = i.KeyBankRegFinlEOP And i.UpdOperation <> 2
JOIN SNL..BankRegFinlEOPI2 i2  ON a.KeyBankRegFinlEOP = i2.KeyBankRegFinlEOP And i2.UpdOperation <> 2
JOIN SNL..BankRegFinlEOPII3 ii3  ON a.KeyBankRegFinlEOP = ii3.KeyBankRegFinlEOP And ii3.UpdOperation <> 2
JOIN SNL..BankRegFinlEOPII4 ii4  ON a.KeyBankRegFinlEOP = ii4.KeyBankRegFinlEOP And ii4.UpdOperation <> 2
join snl..Instn ins on ins.KeyInstn = b.KeyInstn
Where a.UpdOperation <> 2 And b.UpdOperation <> 2
And a.DateEnded >= '03/31/2014'   
--and a.CurrentFINLInternal = 1
--and a.RegRestatementBasis <> 1
and ins.gaapdomainclass in (1,2)
and ins.Regdomainclass in (1,2,3)
and ins.gaapcurrent=1
order by keyinstn


select distinct *
from #temp t
inner join #temp t1  
on t.KEyinstn= t1.keyinstn
--where t.BRxB3Tier1CapitalRatio <> t1.BRxB3Tier1CapitalRatio
where t.Keyinstn= 100003
and t.dateended = '2014-03-31 00:00:00'
order by t.keyinstn
drop table #temp

0 个答案:

没有答案