select vehiclename,
sum(case when oil = 'oil1' then volume end) as oil_1,
sum(case when oil = 'oil2' then volume end) as oil_2,
sum(case when oil = 'oil3' then volume end) as oil_3
from the_table
group by vehiclename
order by vehiclename;
If new oil types are added, you need to add one CASE
statement for each value that can show up in the oil
column.
If you need an automatic way of doing that, you will need to use dynamic SQL where you first retrieve the distinct values for the oil
column and then create a SQL statement following the pattern in the above solution. Then run that dynamic SQL statement.