Let's say I have this data, it is the result from a query.
[
[
{
"brgy_locat": "Kauswagan",
"countlow": 8
},
{
"brgy_locat": "Katugasan",
"countlow": 24
},
{
"brgy_locat": "Comagascas",
"countlow": 3
},
{
"counthigh": 7,
"brgy_locat": "Barangay 9"
},
[
{
"brgy_locat": "Barangay 11",
"countmedium": 1
}
],
[],
[],
[],
[
{
"brgy_locat": "Mabini",
"countmedium": 1
}
],
[
{
"counthigh": 27,
"brgy_locat": "Barangay 6"
},
{
"counthigh": 3,
"brgy_locat": "Mabini"
},
{
"counthigh": 2,
"brgy_locat": "Barangay 2"
},
{
"counthigh": 7,
"brgy_locat": "Barangay 9"
},
{
"counthigh": 17,
"brgy_locat": "Comagascas"
},
{
"counthigh": 1,
"brgy_locat": "Tolosa"
},
{
"counthigh": 33,
"brgy_locat": "Barangay 7"
}
]
]
]
I wanted it to be group by brgy_locat and sum all the values from countlow, countmedium and counthigh if brgy_locat is the same.
Somehow like this:
[
{
"brgy_locat": "Kauswagan",
"countlow": 8,
"countmedium": 1,
"counthigh": 5
}
]
Values above are just samples. Take a look at this JSFiddle I made.