Вы можете использовать оператор case
. здесь демо .
select
id,
max(case when value in ('ABC', 'JKL') then value end) as column1,
max(case when value in ('DEF', 'MNO') then value end) as column2,
max(case when value in ('GHI') then value end) as column3
from myTable
group by
id
order by
id
Выход:
id | column1 | column2 | column3
----------------------------------
1 | ABC | DEF | GHI
2 | JKL | MNO | null