Test

0

Please login or register to vote for this query.

(click on this box to dismiss)

Android Enthusiasts

Q&A for enthusiasts and power users of the Android operating system

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


select Firstname, Amount, PostalCode, LastName, AccountNumber
from
(
  select value, columnname
  from #yourtable
) d
pivot
(
  max(value)
  for columnname in (Firstname, Amount, PostalCode, LastName, AccountNumber)
) piv;

Enter Parameters

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