Sql-server – two columns in two rows

pivotsql server

I have this table:

 ID     Value         
 -----------------    
  3       A1                    
  4       A2                    
  8       A20                 
  10      A10  

I have to create only two rows with the name of the columns at the beginning, I think using the pivot, but I don't know how to do it:

 ID        3    4    8    10  
 -----------------------------------    
 Value     A1   A2  A20   A10                 

Best Answer

SELECT 'Value' AS ID, [3], [4], [8], [10]  
FROM test
PIVOT ( MAX(value)  
        FOR id IN ([3], [4], [8], [10])  
      ) AS PivotTable;  

fiddle