CREATE table #yourtable ([value] int, [Alias] varchar(6),...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Japanese Language

Q&A for students, teachers, and linguists wanting to discuss the finer points of the Japanese language

CREATE table #yourtable
    ([value] int, [Alias] varchar(6), [PKMatricula] varchar(13), [ColumnName] varchar(13))
;
    
INSERT INTO #yourtable
    ([value], [Alias], [PKMatricula], [ColumnName])
VALUES
    (399, 'CCS', '4000', 'CCS'),
      (12, 'CBT', '4000', 'CBT'),
    (3, 'GOR', '4000', 'GOR'),
    (3, 'PRO', '4000', 'PRO'),
    (4, 'PRO', '5000', 'PRO')
;


select PKMatricula,CCS, CBT, GOR, PRO
from
(
  select PKMatricula,value, columnname
  from #yourtable
) d
pivot
(
  max(value)
  for columnname in (CCS, CBT, GOR, PRO)
) piv;

Enter Parameters

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