forked from gangadhargo/alasql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest021.js
39 lines (37 loc) · 877 Bytes
/
test021.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
}
describe('Test 21', function () {
it('Aggregators', function (done) {
var db = new alasql.Database('db');
db.exec('CREATE TABLE test (a int, b int)');
db.exec('INSERT INTO test VALUES (1,1)');
db.exec('INSERT INTO test VALUES (2,1)');
db.exec('INSERT INTO test VALUES (3,1)');
db.exec('INSERT INTO test VALUES (4,2)');
db.exec('INSERT INTO test VALUES (5,2)');
db.exec('INSERT INTO test VALUES (6,2)');
var res = db.exec('SELECT b, SUM(a), COUNT(a), FIRST(a), LAST(a) FROM test GROUP BY b');
assert.deepEqual(
[
{
b: 1,
'SUM(a)': 6,
'COUNT(a)': 3,
'FIRST(a)': 1,
'LAST(a)': 3,
},
{
b: 2,
'SUM(a)': 15,
'COUNT(a)': 3,
'FIRST(a)': 4,
'LAST(a)': 6,
},
],
res
);
done();
});
});