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)

Physical Fitness

Q&A for physical fitness professionals, athletes, trainers, and those providing health-related needs

CREATE table #yourtable
    ([Id] int, [Value] varchar(6), [ColumnName] varchar(13), [test] varchar(13))
;
    
INSERT INTO #yourtable
    ([Id], [Value], [ColumnName], [test])
VALUES
    (1, 'John', 'FirstName', 'test010'),
    (2, '2.4', 'Amount', 'test010'),
    (3, 'ZH1E4A', 'PostalCode', 'test010'),
    (4, 'Fork', 'LastName', 'test010'),
    (5, '857685', 'AccountNumber', 'test010')
;


select
  max(case when columnname = 'FirstName' then value end) Firstname,
  max(case when columnname = 'Amount' then value end) Amount,
  max(case when columnname = 'PostalCode' then value end) PostalCode,
  max(case when columnname = 'LastName' then value end) LastName,
  max(case when columnname = 'AccountNumber' then value end) AccountNumber
from #yourtable

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results