“
- select name as ‘商品名’,
- count(case when color=‘白’ then 1 else null end) as ‘白’,
- count(case when color=‘黒’ then 1 else null end) as ‘黒’,
- count(case when color=‘赤’ then 1 else null end) as ‘赤’,
- count(case when color=‘青’ then 1 else null end) as ‘青’,
- count(case when color=‘緑’ then 1 else null end) as ‘緑’
- from history
- group by name
| 商品名 | 白 | 黒 | 赤 | 青 | 緑 |
|---|---|---|---|---|---|
| ビックリ弁当箱 | 1 | 1 | 2 | 1 | 2 |
| 最果てグローブ | 2 | 2 | 2 | 1 | 0 |
| 無駄毛ロンガー | 1 | 0 | 2 | 1 | 2 |