-
Notifications
You must be signed in to change notification settings - Fork 659
Value
Mathias Rangel Wulff edited this page Nov 24, 2015
·
6 revisions
Syntax:
VALUE OF SELECT ...
Alternative syntax:
SELECT VALUE ...
Usually AlaSQL returns array of records (JavaScript objects), but you can modify SELECT statement to return single value from the first line and first column of result recordset:
var data = [{a:1},{a:2}];
var res = alasql('VALUE OF SELECT SUM(a) FROM ?',[data]);
// returns 3
var res = alasql('SELECT COUNT(*) FROM ?',[data]);
// returns [{'COUNT(*)':2}]
var res = alasql('SELECT VALUE COUNT(*) FROM ?',[data]);
// returns 2
You can set query modifier for all SELECTs:
alasql.options.modifier = 'VALUE';
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo