How can I pivot the following SELECT statement:
SELECT sc.CID,
sc.CodeName as OverviewText,
scRAG.CodeName as RAGStatusText
FROM StatusCode sc
LEFT OUTER JOIN ProjectOverview po
ON sc.CID = po.ProjectOverviewCID
AND po.ProjectId = 180
LEFT OUTER JOIN StatusCode scRAG
ON po.RAGStatusCID = scRAG.CID
WHERE sc.SCID = 18
Such statement yields the result set that follows:
CID OverviewText RAGStatusText
--- ------------ -------------
153 Cost Green
154 Requirements Yellow
155 Schedule NULL
156 Technical NULL
157 Testing NULL
But, I want it to return one single row with 10 values, as shown bellow:
----------------------------------------------------------------------------------------------
| Cost | Green | Requirements | Yellow | Schedule | NULL | Technical | NULL | Testing | NULL |
----------------------------------------------------------------------------------------------
Can I pivot on CID
?