Q:

javascript/jquery object inside object json data

I have this data, 
json: 
var data = [{a:1,b:{amount: 10}, c:1},
            {a:2,b:{amount: 20}, c:1}, 
            {a:1,b:{amount: 30}, c:2}
           ];

and I want to do something like this:
SELECT SUM(b.amount) FROM data GROUP BY a, c

A:

You're trying to sum properties in an array of objects.
This will do it for you:
let sum = [];
data.forEach(function(el){
    if(sum[el.a] == undefined) sum[el.a] = []; 
    if(sum[el.a][el.c] == undefined) sum[el.a][el.c] = 0; 
    sum[el.a][el.c] += el.b.amount
});

You can then access the sum for a = 1, c = 2 with sum[1][2].
This code will work with larger data sets which require adding.

