title: MySQL aggregated sum of JSON objects
body: <p>I have created new table and having details as JSON datatype. I tried to get the aggregated sum of all records. I can able to get the each values but I don't know how to get the sum using group by options. </p>
  
  <pre><code>CREATE TABLE `Sample` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `details` json DEFAULT NULL,
    PRIMARY KEY (`id`)
  )  CHARSET=latin1;
  </code></pre>
  
  <p>Sample Data</p>
  
  <pre><code> 1. [{"id": 1, "name": "T1", "amount": "34.34", "percentage": "45"}, {"id": 3, "name": "T3", "amount": "30.34", "percentage": "45"}, {"id": 2, "name": "T2", "amount": "14.34", "percentage": "15"}]
  
   2. [{"id": 1, "name": "T1", "amount": "34.34", "percentage": "45"}, {"id": 2, "name": "T2", "amount": "30.34", "percentage": "45"}, {"id": 4, "name": "T4", "amount": "14.34", "percentage": "15"}]
  </code></pre>
  
  <p>I want the aggregated group of these 2 records</p>
  
  <p>Output data</p>
  
  <pre><code>   [{"id": 1, "name": "T1", "amount": "68.68", "percentage": "45"}, {"id": 3, "name"`enter code here`: "T3", "amount": "30.34", "percentage": "45"}, {"id": 2, "name": "T2", "amount": "44.68", "percentage": "60"}, {"id": 4, "name": "T4", "amount": "14.34", "percentage": "15"}]
  </code></pre>
  
  <p>I tried using JSON_EXTRACT(details, "$[*]") but doesn't work out </p>