1. select name as ‘商品名’,  
  2. count(case when color=‘白’ then 1 else null endas ‘白’,  
  3. count(case when color=‘黒’ then 1 else null endas ‘黒’,  
  4. count(case when color=‘赤’ then 1 else null endas ‘赤’,  
  5. count(case when color=‘青’ then 1 else null endas ‘青’,  
  6. count(case when color=‘緑’ then 1 else null endas ‘緑’  
  7. from history  
  8. group by name  
これを実行すると、

商品名
ビックリ弁当箱11212
最果てグローブ22210
無駄毛ロンガー10212

Notes