title: Get the average of fields in an Array of structs in Bigquery
body: <p>I have a query similar to this one:</p>
  <pre><code>    select id, ARRAY_AGG(STRUCT(name, client_id, locations)) as client,
   from cell_phone_info where ARRAY_LENGTH(locations) &gt; 0 group by id order by id 
  </code></pre>
  <p>where locations is a array with positional information from the cellphone of the user, usualy this array has 5 elements with speed, latitude and longitude information.</p>
  <p>The output is similar to this</p>
  <p>id | client.name | client.id | locations.speed | locations.lat | location.lon</p>
  <p>1  | Jack | 1 | 0.02 | -40.321624 | -20.32365</p>
  <p>++ | ++ |  ++| 0.021 | -40.321624 | -20.32665</p>
  <p>++ | ++ |  ++| 0.021 | -40.321624 | -20.32665</p>
  <p>++ | ++ |  ++| 0.030 | -40.321624 | -20.32665</p>
  <p>++ | ++ |  ++| 0.021 | -40.321624 | -20.32665</p>
  <p>1  | Maria | 2 | 0.03 | -40.321624 | -20.32365</p>
  <p>++ | ++ |  ++| 0.041 | -42.321624 | -20.32665</p>
  <p>++ | ++ |  ++| 0.021 | -42.321624 | -20.32665</p>
  <p>++ | ++ |  ++| 0.033 | -42.321624 | -20.32665</p>
  <p>++ | ++ |  ++| 0.012 | -42.321624 | -20.32665</p>
  <p>I would like to have for each client the average and the standard deviation of the values in the location array.</p>