use hahn;

select
    `date`,
    sum_if(revenue, purchase_type == 'cpm') as cpm_total,
    sum_if(revenue, purchase_type == 'cpm' and product_type != 'video') as display,
    sum_if(revenue, purchase_type == 'cpm' and product_type == 'video') as cpm_video,
    sum_if(revenue, purchase_type == 'cpc' and product_type == 'video') as cpc_video
from `{kub_path}`
where report_date >= '2016-01-01' and report_date < '{to_dt}'
group by
    report_date as `date`
order by `date`;
