CREATE table #yourtable ([Id_row] int,[Id] int, [Value] v...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Italian Language Meta

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

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

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

Enter Parameters

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