title: How to Aggregate and Group By in Google BigQuery
body: <p>In Google BigQuery, I'd like to roll up metrics based on certain dimensions (in this case, by campaign and partner). When I use the code below, I'm getting the error:<br/><br/><i>Expression 'a.genre' is not present in the GROUP BY list. </i><br/><br/>Can someone please advise what I need to fix in my script? Thank you! <br/>Please see below for sample table (disregard how the headers in the table below don't exactly match the provided script):</p>
  
  <p><a href="https://i.stack.imgur.com/29JZs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/29JZs.png" alt="enter image description here"></a></p>
  
  
  
  <pre class="lang-sql prettyprint-override"><code>SELECT
    SUM(a.amount) totalcost, 
    a.campaign_name, 
    c.friendly_campaign, 
    p.friendly_partner_name, 
    a.partner_name, 
    a.genre, 
    a.season, 
    a.package
  FROM
    [TABLE 1] a
    LEFT OUTER JOIN
    [TABLE 2] p
  ON
    a.partner_name = p.raw_partner_name
  LEFT OUTER JOIN
    [TABLE 3] c 
  ON
    a.campaign_name = c.campaign
  GROUP BY ROLLUP(c.friendly_campaign, p.friendly_partner_name)
  </code></pre>