-
Notifications
You must be signed in to change notification settings - Fork 664
Order By
Mathias Rangel Wulff edited this page Jun 12, 2015
·
4 revisions
Syntax:
SELECT ... ORDER BY expression1 [ASC|DESC], ...
You can specify order with keywords:
Ascending:
alasql('SELECT * FROM City ORDER BY Population');
alasql('SELECT * FROM City ORDER BY Population ASC');
Descending:
alasql('SELECT * FROM City ORDER BY Name DESC');
AlaSQL supports number notation for ORDER BY arguments:
var data = [{a:2,b:20},{a:2,b:30},{a:3,b:10}];
var res1 = alasql('SELECT a,b FROM ? ORDER BY 2,1',[data]);
var res2 = alasql('SELECT a,b FROM ? ORDER BY 1 DESC,2 DESC',[data]);
See also: SELECT, [GROUP BY](Group By)
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo