title: Ruby SQL Result to Grouped Hash
body: <p>I am Fetching Data from a proprietary Database (Sybase Advantage ADS)
  Through a self written API that utilizes PHP and return the Results as JSON</p>
  
  <p>so i have a Result that looks like this</p>
  
  <pre><code>[   
    {"year"=&gt;"2016", "month"=&gt;"1", "total"=&gt;"1223"},  
    {"year"=&gt;"2016", "month"=&gt;"2", "total"=&gt;"613"},   
    {"year"=&gt;"2016", "month"=&gt;"3", "total"=&gt;"12351"},  
    {"year"=&gt;"2017", "month"=&gt;"1", "total"=&gt;"123123"},   
    {"year"=&gt;"2017", "month"=&gt;"2", "total"=&gt;"613123"},
    {"year"=&gt;"2017", "month"=&gt;"3", "total"=&gt;"123"}
  ]
  </code></pre>
  
  <p>This is what i retrieve in Ruby, now in Order to work with the Date i'd like to create a Hash like this : </p>
  
  <pre><code>[  
    {:name =&gt; "2017", :data =&gt; {"1" =&gt; 123123, "2" =&gt; 613123, "3" =&gt; 123}},  
    {:name =&gt; "2016", :data =&gt; {"1" =&gt; 1223, "2" =&gt; 613, "3" =&gt; 12351}}  
  ]
  </code></pre>
  
  <p>This big array is ment to be split and merged by the year key, with each combination of month and total in it.</p>
  
  <p>Furthermore i want to utilize the value of month as the key for total.</p>
  
  <p>Any little help to get me started would be greatly appreciated.</p>