title: How to get the most frequent value in Google's Bigquery
body: <p>Postgres has an easy function to achieve this, just using the <a href="https://wiki.postgresql.org/wiki/Aggregate_Mode" rel="noreferrer">mode()</a> function we can find the most frequent value. Is there something equivalent within Google's Bigquery?</p>
  
  <p>How could be written a query like this in Bigquery?</p>
  
  <pre><code>select count(*),
         avg(vehicles)                                         as mean,
         percentile_cont(0.5) within group (order by vehicles) as median,
         mode() within group (order by vehicles)               as most_frequent_value
  FROM "driver"
  WHERE vehicles is not null;
  </code></pre>