-
Notifications
You must be signed in to change notification settings - Fork 664
Group By
Andrey Gershun edited this page May 28, 2015
·
7 revisions
Syntax:
SELECT ... GROUP BY expression, expression...
SELECT ... GROUP BY CUBE(expression,...) | ROLLUP(expression,...) | GROUPING SETS(expression,...)
Grouping by columns:
var res = alasql('SELECT * FROM City GROUP BY Contient, Country');
Grouping by expressions:
var res = alasql('SELECT b FROM Nums GROUP BY a%2');
The example:
alasql('SELECT projects, FIRST(duration) AS duration, \
FIRST([path]) AS [path], FIRST(application) AS application \
FROM json("timing_output") \
GROUP BY projects, duration, [path], application \
ORDER BY duration DESC',[],function(res){
console.log(res);
});
Try this example in jsFiddle
alasql('SELECT * FROM City GROUP BY ROLLUP(Continent, Country)');
See jsFiddle example for ROLLUP(), CUBE(), and GROUPING SETS().
See also: SELECT, HAVING, CUBE, ROLLUP, [GROUPING SETS](Grouping Sets)
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo