Agrupar por advert_id
y usar una agregación condicional
select advert_id,
sum(type = 'click') as clicks,
sum(type = 'view') as views
from your_table
group by advert_id
Agrupar por advert_id
y usar una agregación condicional
select advert_id,
sum(type = 'click') as clicks,
sum(type = 'view') as views
from your_table
group by advert_id