title: BigQuery: How to Avoid "Resources exceeded during query execution." error
body: <p>I'm wondering how I can avoid the "resources exceeded during execution" error. Most of the other questions on about this involve JOIN EACH or GROUP EACH BY, but I'm already not using those. If I include the WHERE clause on the date or the ABS(HASH(userId)), then the query works, but I'd like to have the entire data set available and then I'm going to filter it further in Tableau. </p>
  
  <p>If I remove t4 the query works, but I want that last column, and I'll want even more columns created out of the event_parameters field for later queries. </p>
  
  <p>Job ID was rhi-localytics-db:job_6MaesvuMK6mP6irmAnrcM9R3cx8 in case that helps, Thanks.</p>
  
  <pre><code>SELECT
      t1.userId as userId,
      t1.event_time AS event_time,
      t1.Diamond_Balance as Diamond_Balance,
      t2.Diamond_Change as Diamond_Change,
      t3.Gold_Balance as Gold_Balance,
      t4.Gold_Change as Gold_Change
  FROM (
      SELECT
          userId,
          event_time,
          INTEGER(event_parameters.Value) AS Diamond_Balance,
      FROM
          FLATTEN([game_data], event_parameters)
      WHERE
          event_name LIKE 'Currency'
          AND event_parameters.Name = 'Diamond_Balance'
          -- and date(event_time) &gt; '2015-09-11'
          -- AND ABS(HASH(userId) % 5)  = 0
      GROUP BY
          userId,
          event_time,
          Diamond_Balance ) AS t1
  INNER JOIN (
      SELECT
          userId,
          event_time,
          INTEGER(event_parameters.Value) AS Diamond_Change,
      FROM
          FLATTEN([game_data], event_parameters)
      WHERE
          event_name LIKE 'Currency'
          AND event_parameters.Name = 'Diamond_Change'
          AND INTEGER(event_parameters.Value ) &lt; 14000
          AND INTEGER(event_parameters.Value ) &gt; -14000
          -- and date(event_time) &gt; '2015-09-11'
          -- AND ABS(HASH(userId) % 5)  = 0
  
      GROUP BY
          userId,
          event_time,
          Diamond_Change ) AS t2
  ON
      t1.userId = t2.userId
      AND t1.event_time = t2.event_time
  INNER JOIN (
      SELECT
          userId,
          event_time,
          event_parameters.Value AS Gold_Balance,
      FROM
          FLATTEN([game_data], event_parameters)
      WHERE
          event_name LIKE 'Currency'
          AND event_parameters.Name = 'Gold_Balance'
          -- and date(event_time) &gt; '2015-09-11'
          -- AND ABS(HASH(userId) % 5)  = 0
  
      GROUP BY
          userId,
          event_time,
          Gold_Balance ) AS t3
  ON
      t1.userId = t3.userId
      AND t1.event_time = t3.event_time
  INNER JOIN (
      SELECT
          userId,
          event_time,
          INTEGER(event_parameters.Value) AS Gold_Change,
      FROM
          FLATTEN([game_data], event_parameters)
      WHERE
          event_name LIKE 'Currency'
          AND event_parameters.Name = 'Gold_Change'
          -- and date(event_time) &gt; '2015-09-11'
          -- AND ABS(HASH(userId) % 5)  = 0
      GROUP BY
          userId,
          event_time,
          Gold_Change ) AS t4
  ON
      t1.userId = t4.userId
      AND t1.event_time = t4.event_time
  </code></pre>