title: SQL: select top elements from groups based on count
body: <p>I have three tables:</p>
  <ol>
  <li><p>First Block of Query: it computes the impressions</p>
  </li>
  <li><p>Second Block of Query: it computes the conversions</p>
  </li>
  <li><p>Then I am joining to create another table</p>
  </li>
  </ol>
  <hr />
  <pre><code>create table stage_II_final_suzuki_1648436600 as
          select a.*,b.conversions, b.total_users 
          from tmp.stage_II_imps_suzuki_1648436600 a
          join 
          tmp.stage_II_conversions_suzuki_1648436600 b
          on a.domain = b.domain
             and a.ad_position = b.ad_position
             and a.browser_id = b.browser_id
             and a.hour_of_day = b.hour_of_day
             and a.day_of_week = b.day_of_week
             and a.exchange_id = b.exchange_id
             and a.device_type = b.device_type
          ORDER BY b.total_users;
  </code></pre>
  <p>The output is:</p>
  <p>domain, ad_position, hour_of_day, browser_id, exchange_id, day_of_week, device_type, impressions, conversions, total users</p>
  <p>Now, how shall I return feature values (~20%) of which caters ~80% of users.?</p>
  <p>Features: domain, ad_position, browser_id, hour_of_day, day_of_week, exchange_id, device_type</p>
  <p>so for an example,</p>
  <p>browser-user share
  chrome - 55%
  Mozila FF - 17%
  MS Edge - 12%
  Safari - 15%
  duck duck go - 0.5%
  Then result should be Chrome, Mozila and Safari</p>
  <p>and similarly for all features</p>