Use `case` statement to convert values into columns:
select id, case when ProductType = 'car' then 1 end as car,
case when ProductType = 'bike' then 1 end as bike,
case when ProductType = 'truck' then 1 end as truck
from your_table;
OK
id car bike truck
1 1 NULL NULL
2 NULL 1 NULL
3 NULL NULL 1
Time taken: 35.442 seconds, Fetched: 3 row(s)
1条答案
按热度按时间l7wslrjt1#