Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to do inside quotes
Message
De
11/09/2013 12:41:31
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 6.5 and older
Application:
Web
Divers
Thread ID:
01582787
Message ID:
01582874
Vues:
32
>>>
>>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform