title: Aggregate using 2 arrays and keep contribution information
body: <p><strong>Issue</strong></p>
  <p>Want to aggregate rows, but still keep information of how rows tributes to the final sum.</p>
  <p>The information is in two arrays, but can't figure out how to aggregate it and keep information.</p>
  <p><strong>Schema &amp; sample data</strong> (simplified)</p>
  <pre><code>CREATE TABLE A 
  (
      Groupkey Int32,
      Sizename String,
      Givenqty Array(int),
      Category Array(int)
  ) Engine = Memory ;
                  
  INSERT INTO A VALUES (1, 'XS', [1], [154]);               
  INSERT INTO A VALUES (1, 'M', [1], [154]);               
  INSERT INTO A VALUES (1, 'L', [1], [154]);                
  INSERT INTO A VALUES (1, 'XL', [1,1,2,1,1], [145,145,146,154,145]);
  
  SELECT * FROM A:
  </code></pre>
  <p><a href="https://i.stack.imgur.com/IMgNi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IMgNi.png" alt="Sample data" /></a></p>
  <p><strong>Desired result</strong></p>
  <p>I would like 1 aggregated row with the sum of &quot;givenqty pr category&quot;.</p>
  <p>The result should be: (145 = 3, 146 = 2, 154= 4):</p>
  <p><a href="https://i.stack.imgur.com/7WTjg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7WTjg.png" alt="Result" /></a></p>
  <p>When doing the query I know the possible outcomes of the &quot;Category&quot; column, so we can use this information to add the value by index (sorted by categorynumber).</p>
  <p>The number of categories can be random in the data, but the full range is known when querying the data (can be used as a helping array if solution requires it).</p>
  <p>I've tried different kinds of groupArray, tuples etc, but can't seem to get I solved :/</p>