title: How to get multiple event_params as column in BigQuery
body: <p><strong>What I need</strong>: total occurrences of event and the data associated to this event.</p>
  
  <p><strong>What I tried:</strong> in the devices I sent some events to Firebase Analytics. Events look like:</p>
  
  <pre><code>event_name = "business_global_view_profile"
  </code></pre>
  
  <p>with params:</p>
  
  <pre><code>business_global_name :String
  business_global_city:String
  business_global_ID:String
  </code></pre>
  
  <p>So in BigQuery I got something like (between a lot more of values and events that are not need for this):</p>
  
  <p><a href="https://i.stack.imgur.com/XoONt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XoONt.png" alt="enter image description here"></a></p>
  
  <p>I need to obtain ONLY the params I sent, so I need to discard all the stuff like <code>ga_session_id</code>, <code>firebase_event_origin</code>, etc...</p>
  
  <p>So first I tried to "filter" the event I need from all the other events :</p>
  
  <pre><code>SELECT params.key AS ParamKey, params.value.string_value as Value
  FROM `xxxxxx.xxxxx.xxxxx`,
  UNNEST(event_params) as params
  WHERE event_name = "business_global_view_profile"
  </code></pre>
  
  <p>After that I get a table like:</p>
  
  <p><a href="https://i.stack.imgur.com/y9F1M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y9F1M.png" alt="enter image description here"></a></p>
  
  <p>At this moment I achieved get the count of the occurrences by ID</p>
  
  <pre><code>SELECT Value AS BusinessID, COUNT(Value) Occurrences
    FROM(SELECT params.key AS ParamKey, params.value.string_value as Value
    FROM `xxxxxx.xxxxx.xxxxx`,
    UNNEST(event_params) as params
    WHERE event_name = "business_global_view_profile"
    AND event_date = "20190409")
  WHERE ParamKey = "business_global_ID"
  Group by Value
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/SDU1Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SDU1Q.png" alt="enter image description here"></a></p>
  
  <p>But here is where I'm lost, because What I need is something like:</p>
  
  <pre><code>|BusinessID | Occurrences | BusinessName | BusinessCity |
  </code></pre>
  
  <p>Where</p>
  
  <ul>
  <li><code>BusinessName = business_global_name</code> </li>
  <li><code>BusinessCity = business_global_city</code></li>
  </ul>
  
  <p>How can I get all this info together? For sure there is a shorter way to do it, but I'm haven't worked to much with SQL</p>