question

fashraf avatar image
fashraf asked

Display Same Column in Pivot manner

I have a row which displays some information. I need to display the 4 rows into columns with different names.Like Col1,Col2,Col3,Col4![alt text][1] [1]: /storage/temp/4027-1121.jpg Thanks.
pivotmssqlcolumns
1121.jpg (5.6 KiB)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sean_Smith avatar image Sean_Smith commented ·
Like this? CREATE TABLE #temp (rss_name VARCHAR (20)) INSERT INTO #temp VALUES ('BBC-Sports'), ('Talk Sports'), ('Sky Sports'), ('Crick Info') SELECT MAX (CASE WHEN rss_name = 'BBC-Sports' THEN rss_name END) AS col1 ,MAX (CASE WHEN rss_name = 'Talk Sports' THEN rss_name END) AS col2 ,MAX (CASE WHEN rss_name = 'Sky Sports' THEN rss_name END) AS col3 ,MAX (CASE WHEN rss_name = 'Crick Info' THEN rss_name END) AS col4 FROM #temp DROP TABLE #temp
0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.