-
Notifications
You must be signed in to change notification settings - Fork 664
Avg
Andrey Gershun edited this page May 25, 2015
·
6 revisions
AlaSQL supports AVG aggregator.
For example:
var data = [{a:1, b:100},{a:2, b:90},{a:3, b:80},
{a:4, b:70},{a:5, b:60},{a:6, b:50},
{a:7, b:40},{a:8, b:30},{a:9, b:20},
{a:10, b:10}];
var res = alasql('SELECT COUNT(*), SUM(a), AVG(a),\
SUM(b), AVG(b) FROM ?',[data]);
You can try this example in jsFiddle
Note: AlaSQL (like other SQL implementations) does not take in account NULL
(undefined) values.
You can use AVG like other aggregators with DISTINCT
keyword:
SELECT AVG(DISTINCT age) FROM people
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo