SHARE
TWEET

Untitled

a guest Jan 12th, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mysql> select sum(requests) from Stats;
  2.    
  3. SELECT
  4. s.requests,s.impression,s.bad_requests,s.empty_body,s.bad_vast,s.exceptions,s.midpoint,s.complete,s.click,
  5.     (s.impression / s.requests) * 100 as req_fill,
  6.     (s.click / s.impression) * 100 as ctr,(s.complete / s.impression) * 100 as completion,
  7.     s.media_cost,s.revenue
  8.     FROM (
  9.         SELECT SUM(t.requests) AS requests, SUM(t.impression) AS impression, SUM(t.bad_requests) AS bad_requests, SUM(t.empty_body) AS empty_body, SUM(t.bad_vast) AS bad_vast, SUM(t.exceptions) AS exceptions, SUM(t.midpoint) AS midpoint, SUM(t.complete) AS complete, SUM(t.click) AS click,
  10.         SUM(IF(p.rate_type = "0", (t.impression * p.fixed_rate) / 1000, (t.impression * d.rate) / 1000 * (p.percent_rate / 100))) as media_cost,
  11.         SUM((t.impression * d.rate) / 1000) as revenue
  12.         FROM 7days_Stats t
  13.         JOIN Demands d ON d.id = t.demand_tag_id
  14.         JOIN Supplies p ON p.id = t.supply_tag_id
  15.     ) s;
RAW Paste Data
Top