title: BigQuery and GROUP BY clause
body: <p>I'm trying to figure out how Google BigQuery works in respect to aggregation and grouping. I read the documentation and it says for GROUP BY this:</p>
  
  <blockquote>
    <p>The GROUP BY clause allows you to group rows that have the same values
    for a given field. You can then perform aggregate functions on each of
    the groups. Grouping occurs after any selection or aggregation in the
    SELECT clause.</p>
  </blockquote>
  
  <p>So it says that after grouping I can perform aggregate functions (I assume that's functions like COUNT). But than the sentence later it says that grouping occurs after any selection or aggregation in the SELECT clause.</p>
  
  <p>So if I have</p>
  
  <pre><code>SELECT f1, COUNT(f2)
    FROM ds.Table
    GROUP BY f1;
  </code></pre>
  
  <p>Which happens first, grouping or counting?</p>