JSFiddle - React, Tailwind, and code Playground
by bilbobaggins
JavaScript
let red=`[
{
Name: 'A',
Time: '2019-11-15T14:12:00.000Z',
Value: '2'
},
{
Name: 'A',
Time: '2019-11-15T14:12:01.000Z',
Value: '3'
}
,
{
Name: 'B',
Time: '2019-11-15T14:12:04.000Z',
Value: '1'
},
{
Name: 'C',
Time: '2019-11-15T14:12:00.000Z',
Value: '2'
},
{
Name: 'C',
Time: '2019-11-15T14:12:01.000Z',
Value: '3'
}
]`
red=JSON.parse(JSON.stringify(eval("(" + red + ")")));
var doctors = red.map(function(doctor) {
var o= new Object()
Object.keys(doctor).map(function(keys) {
return { // return what new object will look like
keys:doctor[keys]
}
})
return o // return what new object will look like
});
console.log(doctors)
var res = alasql('SELECT Name, Sum(Value) \
FROM ? \
GROUP BY Name \
',[red]);
console.log(res)