1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
select PR.ReferenceDate as ValDate,
PMD.Key1 as Key1, PMD.Key2 as Key2, sum(VTR.BasePV) - PBT.BasePV as PV, pr.PortfolioID, sc.Description
from panorama..valuationtabresults VTR,
panorama..PartitionMapData PMD,
panorama..PortfolioResults PR,
#PBT as PBT, #tmp tmp
, panorama..Scenario2 sc
where VTR.ResultsID=PR.ResultsID
and PR.PortfolioID= @vpID
and pmd.Key4 in ('txde', 'txpr', 'txob')
and PR.ReferenceDate > (case when @DateFixingHisto >cast('20091101' as datetime) then
@DateFixingHisto
else
cast('20091101' as datetime)
end)
and PR.ReferenceDate != '20091111'
and VTR.UserPartitionID = PMD.PartitionCode
and pr.ReferenceDate=PBT.ReferenceDate
and tmp.K1 = pmd.Key1 and tmp.K2= pmd.Key2
and tmp.K1 = sc.ScenarioID
group by pr.ReferenceDate,pmd.Key1, pmd.key2, pr.PortfolioID,PBT.BasePV,sc.Description |
Partager