<t>There are several ways that you can transform data from multiple rows into columns.<br/>
<br/>
Using PIVOT<br/>
<br/>
In SQL Server you can use the PIVOT function to transform the data from rows to columns:<br/>
<br/>
select Firstname, Amount, PostalCode, LastName, AccountNumber<br/>
from<br/>
(<br/>
select value, columnname<br/>
from yourtable<br/>
) d<br/>
pivot<br/>
(<br/>
max(value)<br/>
for columnname in (Firstname, Amount, PostalCode, LastName, AccountNumber)<br/>
) piv;<br/>
<br/>
```<br/>
<br/>
See [Demo](https://data.stackexchange.com/stackoverflow/query/497432).<br/>
<br/>
Pivot with unknown number of `columnnames`<br/>
<br/>
If you have an unknown number of `columnnames` that you want to transpose, then you must use dynamic SQL:<br/>
<br/>
```<br/>
DECLARE @cols AS NVARCHAR(MAX),<br/>
@query AS NVARCHAR(MAX)<br/>
<br/>
select @cols = STUFF((SELECT ',' + QUOTENAME(ColumnName) <br/>
from yourtable<br/>
group by ColumnName, id<br/>
order by id<br/>
FOR XML PATH(''), TYPE<br/>
).value('.', 'NVARCHAR(MAX)') <br/>
,1,1,'')<br/>
<br/>
set @query = N'SELECT ' + @cols + N' from <br/>
(<br/>
select value, ColumnName<br/>
from yourtable<br/>
) x<br/>
pivot <br/>
(<br/>
max(value)<br/>
for ColumnName in (' + @cols + N')<br/>
) p '<br/>
<br/>
exec sp_executesql @query;<br/>
<br/>
```<br/>
<br/>
See [Demo](https://data.stackexchange.com/stackoverflow/query/497433).<br/>
<br/>
Using an aggregate function<br/>
<br/>
If you do not want to use the `PIVOT` function, then you can use an aggregate function with a `CASE` expression:<br/>
<br/>
```<br/>
select<br/>
max(case when columnname = 'FirstName' then value end) Firstname,<br/>
max(case when columnname = 'Amount' then value end) Amount,<br/>
max(case when columnname = 'PostalCode' then value end) PostalCode,<br/>
max(case when columnname = 'LastName' then value end) LastName,<br/>
max(case when columnname = 'AccountNumber' then value end) AccountNumber<br/>
from yourtable<br/>
<br/>
```<br/>
<br/>
See [Demo](https://data.stackexchange.com/stackoverflow/query/497434).<br/>
<br/>
Using multiple joins<br/>
<br/>
This could also be completed us<br/>
<br/>
*(Réponse tronquée)*</t>