Alasql: "Parse error on line 1:↵...LECT type, SUM(count) AS…-------------^↵Expecting 'LPAR', got 'RPAR'"

Created on 14 Aug 2016  Â·  2Comments  Â·  Source: agershun/alasql

Hi have the following object below which is a breeze.js entity. I am trying to do a basic group by function. In this case it is throwing an error. Is the issue is that Breeze entities are not supported? Basic select statements are working fine on this object!

count:1
description:"1 sweepstake ticket"
displayName:"1 sweepstake ticket"
payload:"1"
rewardId:14
type:3
    var res = alasql('SELECT type, SUM(count) AS b FROM ? group by type', [data]);
     console.log(res);

Getting this error:

{message: "Parse error on line 1:↵...LECT type, SUM(count) AS…-------------------^↵Expecting 'LPAR', got 'RPAR'", hash: Object}hash: Objectexpected: Array[1]0: "'LPAR'"length: 1__proto__: Array[0]line: 0loc: Objecttext: ")"token: "RPAR"__proto__: Objectmessage: "Parse error on line 1:↵...LECT type, SUM(count) AS b FROM ? group ↵-----------------------^↵Expecting 'LPAR', got 'RPAR'"__proto__: Error()(anonymous function) @ angular.js:11655(anonymous function) @ angular.js:8596(anonymous function) @ angular.js:13256$eval @ angular.js:14466$digest @ angular.js:14282(anonymous function) @ angular.js:14505e @ angular.js:4924(anonymous function) @ angular.js:5312
8notificationService.js:84 poller callback

Thanks
Jordan

Please test

Most helpful comment

Here count is a AlaSQL's keyword, so can you rewrite the query with enclosed [count] or backquotes count:

    var res = alasql('SELECT type, SUM([count]) AS b FROM ? GROUP BY type', [data]);

All 2 comments

Here count is a AlaSQL's keyword, so can you rewrite the query with enclosed [count] or backquotes count:

    var res = alasql('SELECT type, SUM([count]) AS b FROM ? GROUP BY type', [data]);

It worked, great stuff. Trying to get comfortable with the language and think I have another question to post about searching and returning multiple fields then grouping them with a SUM.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SWard1992 picture SWard1992  Â·  3Comments

mwhebert picture mwhebert  Â·  3Comments

umasudhan picture umasudhan  Â·  4Comments

Serge-SDL picture Serge-SDL  Â·  4Comments

AmyBlankenship picture AmyBlankenship  Â·  6Comments