JSFiddle - React, Tailwind, and code Playground

by Andrey Gershun

HTML

<script src="http://alasql.org/console/alasql.min.js"></script>
    <p>Result: <span id="res"></span></p>

JavaScript

var json = [
    {"a":121, "b":212, "c":"0", "d":100},
    {"a":121, "b":212, "c":"0", "d":300},
    {"a":121, "b":210, "c":"0", "d":200},
    {"a":120, "b":210, "c":"0", "d":300}
    ];

var res = alasql('SELECT a,b,c,SUM(d) AS d,COUNT(*) AS [count] FROM ? GROUP BY a,b,c',[json]);

document.getElementById("res").textContent = JSON.stringify(res);