Sunday, October 26, 2014

Convert row values to columns

Sounds like this to me



SELECT ProjectName,
[1] AS Value1,
[2] AS value2,
[3] AS Value3,
[4] AS Value4,
[5] AS Value5,
[6] AS Value6
FROM
(
SELECT ROW_NUMBER() OVER (PARTITION BY proj.ProjectName ORDER BY proj.ProjectName) AS Seq,
proj.ProjectName, lt.MemberFullValue
FROM dbo.MSP_EpmProject_UserView AS proj
LEFT JOIN [dbo].[MSPCFPRJ_IT Pillar(s)_AssociationView] AS itpillar
ON proj.ProjectUID = itpillar.EntityUID
LEFT JOIN dbo.MSP_EpmLookupTable AS lt
ON itpillar.LookupMemberUID = lt.MemberUID
)t
PIVOT (MAX(MemberFullValue) FOR Seq IN ([1],[2],[3],[4],[5],[6]))p



to make it dynamic you can use this


http://ift.tt/1cOmTxL


If this is not what you're after, post some sample data and explain the required output




Please Mark This As Answer if it solved your issue

Please Mark This As Helpful if it helps to solve your issue

Visakh

----------------------------

My MSDN Page

My Personal Blog

My Facebook Page


No comments:

Post a Comment