title: How can I select the last index of a column split with bigquery
body: <p>There are a lot of questions about splitting a BigQuery, MySQL column, but I can't find one that fits my situation.</p>
  
  <p>I am processing a large dataset (3rd party) that includes a freeform location field to normalize it for my Android app. When I run a <code>select</code> I'd like to split the column data by commas, take only the last segment and trim it of whitespace.</p>
  
  <p>So far I've come up with the following by Googling documentation:</p>
  
  <pre><code>SELECT RTRIM(LOWER(SPLIT(location, ',')[OFFSET(-1)])) FROM `users` WHERE location &lt;&gt; ''
  </code></pre>
  
  <p>But the <code>-1</code> trick to split at last element does not work (with either offset or ordinal). I can't use <code>ARRAY_LENGTH</code> with the same array inline and I'm not exactly sure how to structure a nested query and know the last column index of the row.</p>
  
  <p>I might be approaching this from the wrong angle, I work with Android and NoSQL now so I haven't used MySQL in a long time</p>
  
  <p><strong>How do I structure this query correctly?</strong></p>