You can use the PIVOT function to get the result. If you have a known number of values, then you can hard-code the query similar to the following:
select type, color,
[1], [1.5], [2], [3], [4]
from
(
select type, color, length, price
from items
) d
pivot
(
max(price)
for length in ([1], [1.5], [2], [3], [4])
) piv
order by type;
See SQL Fiddle with Demo. But if you are going to have an unknown number of length
values, then you will need to use dynamic SQL:
DECLARE @cols AS NVARCHAR(MAX),
@query AS NVARCHAR(MAX)
select @cols = STUFF((SELECT ',' + QUOTENAME(length)
from items
group by length
order by length
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)')
,1,1,'')
set @query = 'SELECT type, color, ' + @cols + '
from
(
select type, color, length, price
from items
) x
pivot
(
max(price)
for length in (' + @cols + ')
) p
order by type'
execute sp_executesql @query;
See SQL Fiddle with Demo