use hahn;

-- moved from https://hitman.yandex-team.ru/projects/wmc-5084/

insert into `//home/webmaster/users/aleksart/wmc-5084/monthly/part` with truncate
select o.month as month, 
    w.Shows*1e0/o.Shows as Shows, 
    w.Clicks*1e0/o.Clicks as Clicks,  
    w.Cost/o.Cost as Cost
    from `//home/webmaster/users/aleksart/wmc-5084/monthly/webmaster` as w
    join `//home/webmaster/users/aleksart/wmc-5084/monthly/other` as o
    on o.month == w.month;
    
insert into `//home/webmaster/users/aleksart/wmc-5084/weekly/part` with truncate
select o.week as week, 
    w.Shows*1e0/o.Shows as Shows, 
    w.Clicks*1e0/o.Clicks as Clicks,    
    w.Cost/o.Cost as Cost
    from `//home/webmaster/users/aleksart/wmc-5084/weekly/webmaster` as w
    join `//home/webmaster/users/aleksart/wmc-5084/weekly/other` as o
    on o.week == w.week;
    
insert into `//home/webmaster/users/aleksart/wmc-5084/daily/part` with truncate
select o.day as day, 
    w.Shows*1e0/o.Shows as Shows, 
    w.Clicks*1e0/o.Clicks as Clicks,   
    w.Cost/o.Cost as Cost
    from `//home/webmaster/users/aleksart/wmc-5084/daily/webmaster` as w
    join `//home/webmaster/users/aleksart/wmc-5084/daily/other` as o
    on o.day == w.day;
