Skip to content

Grouping Sets

Mathias Rangel Wulff edited this page Jun 12, 2015 · 2 revisions

Keyword GROUPING SETS

AlaSQL supports GROUPING SETS() grouping options:

var testData = [
    { Phase: "Phase 1", Step: "Step 1", Task: "Task 1", Val: 5 },
    { Phase: "Phase 1", Step: "Step 2", Task: "Task 2", Val: 20 },
    { Phase: "Phase 2", Step: "Step 1", Task: "Task 1", Val: 25 },
    { Phase: "Phase 2", Step: "Step 2", Task: "Task 2", Val: 40 }
];

res = alasql('SELECT Phase, Step, SUM(Val) AS Val FROM ? \
                  GROUP BY GROUPING SETS(Phase,Step)', [testData]);

Try this example in jsFiddle

Clone this wiki locally