Skip to content
Mathias Rangel Wulff edited this page Nov 24, 2015 · 6 revisions

Keyword VALUE

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';

See also: MATRIX, COLUMN, ROW, RECORDSET

Clone this wiki locally