Вы можете сделать условное агрегирование:
select id, label,
count(distinct case when action = 'A' then action end) as action_a,
count(distinct case when action = 'B' then action end) as action_b
from t
group by id, label;
ИЛИ Вы можете просто использовать max()
:
select id, label,
max(case when action = 'A' then 1 else 0 end) as action_a,
max(case when action = 'B' then 1 else 0 end) as action_b
from t
group by id, label;