SELECT FundingRowID,
AgreementSeriesID,
AgreementSeriesName,
FundingRowDescription,
FundingStatus,
RecipientName,
FederalSharePercentage,
' ' AS Empty,
max([2009]) AS F2009, max([2010]) AS F2010, max([2011]) AS F2011, max([2012]) AS F2012, max([2013]) AS F2013,
max([2009N]) as N2009, max([2010N]) as N2010, ... and so on ....
FROM (SELECT FundingRowID,
AgreementSeriesID,
AgreementSeriesName,
FundingRowDescription,
FundingStatus,
RecipientName,
FederalSharePercentage,
FiscalStartYear,
cast(FiscalStartYear as varchar) + 'N' as FYearNotes
EstimatedAmount
FROM FundingYearly
WHERE AgreementSeriesID = 40
) fy
PIVOT (SUM(EstimatedAmount) FOR FiscalStartYear IN ([2009], [2010], [2011], [2012], [2013])) AS pvt
PIVOT (MAX(fundingNotes) FOR FYearNotes IN ([2009N], [2010N], [2011N], [2012N], [2013N])) AS pvt2
group by FundingRowID,
AgreementSeriesID,
AgreementSeriesName,
FundingRowDescription,
FundingStatus,
RecipientName,
FederalSharePercentage
|