>>>
>>>Did you try running
>>>
>>>
>>>;with cte as (
>>>SELECT sponsor, fundtype, amount
>>>FROM TIP_ApprovedFunding f
>>>INNER JOIN TIP_Projects p ON p.TipID = f.TipID
>>>WHERE p.ApprovedStatus = 'Active'
>>>)
>>> SELECT * from cte
>>> PIVOT
>>> (
>>> SUM(amount) FOR FundType IN ([HSIP], [PL], [SPR], [STP], [TAP])
>>> )
>>> AS PivotTableAlias
>>>
>>>
>>>This should work.
>>>
>>>Also, it should be
>>>execute (@SQL)
>>>
>>>Note the parenthesis.
>>
>>Would you also know how to sort the result by Sponsor? Seems like it doesn't like ORDER BY no matter where I put it.
>
>It should be after AS PivotTableAlias ORDER BY Sponsor
As always, it's the one I didn't try. :(
Thanks