Grouper par advert_id
et utiliser une agrégation conditionnelle
select advert_id,
sum(type = 'click') as clicks,
sum(type = 'view') as views
from your_table
group by advert_id
Grouper par advert_id
et utiliser une agrégation conditionnelle
select advert_id,
sum(type = 'click') as clicks,
sum(type = 'view') as views
from your_table
group by advert_id