vtger.blogg.se

Convert excel row to column
Convert excel row to column




Max(case when columnname = 'LastName' then value end) LastName,

convert excel row to column

Max(case when columnname = 'PostalCode' then value end) PostalCode,

convert excel row to column

Max(case when columnname = 'Amount' then value end) Amount, Max(case when columnname = 'FirstName' then value end) Firstname, If you do not want to use the PIVOT function, then you can use an aggregate function with a CASE expression: select Select = STUFF((SELECT ',' + QUOTENAME(ColumnName)Įxec sp_executesql Demo. If you have an unknown number of columnnames that you want to transpose, then you can use dynamic SQL: DECLARE AS AS NVARCHAR(MAX) In SQL Server you can use the PIVOT function to transform the data from rows to columns: select Firstname, Amount, PostalCode, LastName, AccountNumberįor columnname in (Firstname, Amount, PostalCode, LastName, AccountNumber)

convert excel row to column

There are several ways that you can transform data from multiple rows into columns.






Convert excel row to column