CREATE table #yourtable ([Id] int, [Value] varchar(6), [c...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Philosophy Meta

Q&A about the site for those interested in the study of the fundamental nature of knowledge, reality, and existence

CREATE table #yourtable
    ([Id] int, [Value] varchar(6), [cc] varchar(13))
;
    
INSERT INTO #yourtable
    ([Id], [Value], [cc])
VALUES
    (1, 'John', 'a1'),
    (2, '2.4', 'a2'),
    (3, 'ZH1E4A', 'a3'),
    (4, 'Fork', 'a4'),
    (5, '857685', 'a5')
;


select a1, a2, a3, a4, a5
from
(
  select value, cc
  from #yourtable
) d
pivot
(
  max(value)
  for cc in (a1, a2, a3, a4, a5)
) piv;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results