JSFiddle - React, Tailwind, and code Playground
by Andrey Gershun
HTML
<script src="http://alasql.org/console/alasql.min.js"></script>
<p>Result 1: <span id="res1"></span></p>
JavaScript
var chargeamountunitLevel =[
{
"chargeAmount": 4,
"chargeAmountUnit": "per hour",
"currencyCode": "USD"
},
{
"chargeAmount": 50,
"chargeAmountUnit": "per hour",
"currencyCode": "USD"
},
{
"chargeAmount": 25,
"chargeAmountUnit": "per month",
"currencyCode": "USD"
},
{
"chargeAmount": 25,
"chargeAmountUnit": "per month",
"currencyCode": "USD"
}
];
var res1 = alasql('SELECT SUM(chargeAmount) AS chargeAmount, chargeAmountUnit, currencyCode FROM ? GROUP BY chargeAmountUnit, currencyCode',[chargeamountunitLevel ]);
document.getElementById("res1").textContent = JSON.stringify(res1);