CREATE table #wp_usermeta ([Id] int, [meta_key] varchar(6...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Puzzling Meta

Q&A for those who study the creation and solving of puzzles

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


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

Enter Parameters

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