title: SQL group by middle part of string
body: <p>I have string column that looks usually approximately like this:</p>
  <pre><code>https://mapy.cz/zakladni?x=16.3360208&amp;y=49.6718038&amp;z=8&amp;source=firm&amp;id=13123554
  https://mapy.cz/turisticka?x=15.9380354&amp;y=50.1990211&amp;z=11&amp;source=base&amp;id=2197
  https://mapy.cz/turisticka?x=12.8611357&amp;y=49.8051338&amp;z=16&amp;source=base&amp;id=1703157
  </code></pre>
  <p>I would like to group data by <strong>source</strong> which is part of the string - four letters behind &quot;source=&quot; (in the case above: <code>firm</code>) and then simply count them. Is there a way to achieve this directly in SQL code? I am using hadoop.</p>
  <p>Data is a set of strings that look like above. My expected result is summary table with two columns: 1) Each type of the source (there is about 20 possible and their length is different so I cannot use sipmle substring). Ideally I am looking for solution that says: For the grouping use four letters that come after &quot;source=&quot; 2) Count of their occurences in all the strings.</p>
  <p>There is just one source type in each string.</p>