-
Notifications
You must be signed in to change notification settings - Fork 659
How to group
agershun edited this page Dec 28, 2014
·
1 revision
Source: StackOverflow.com
For example I have this data :
{"date":"2013/06/26","name":"A","number":1}
{"date":"2013/06/26","name":"A","number":5}
{"date":"2013/06/27","name":"B","number":4}
{"date":"2013/06/27","name":"A","number":4}
and I want write like this query but with LINQ for node js
SELECT date, name, SUM(number)
FROM data
GROUPBY date, name
var data = [{"date":"2013/06/26","name":"A","number":1},
{"date":"2013/06/27","name":"A","number":4}];
var res = alasql('SELECT [date], name, SUM(number) AS number \
FROM ? GROUP BY [date], name', [data]);
Try this example at jsFiddle.
Comments: [date] field is in square brackets, because "DATE" is a reserved word for SQL.
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo