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

0

Please login or register to vote for this query.

(click on this box to dismiss)

Emacs

Q&A for those using, extending or developing Emacs

CREATE table #yourtable
    ([Id] int, [Value] varchar(20), [ColumnName] varchar(100))
;
    
INSERT INTO #yourtable
    ([Id], [Value], [ColumnName])
VALUES
    (1, '22334', 'visa_Silver_active_card'),
    (2, '11111', 'visa_GOLD_active_card'),
    (3, '55555', 'visa_PLATINUM_active_card')

;


select visa_Silver_active_card, visa_GOLD_active_card, visa_PLATINUM_active_card
from
(
  select value, columnname
  from #yourtable
) d
pivot
(
  max(value)
  for columnname in (visa_Silver_active_card, visa_GOLD_active_card, visa_PLATINUM_active_card)
) piv;

Enter Parameters

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