/ Check-in [9b43c3ee2e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Implement the EXCLUDE clause for window frames.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | window-functions
Files: files | file ages | folders
SHA3-256: 9b43c3ee2e054b05715573f4f3893b84aabc5100832333c9a0f2a1628552a978
User & Date: dan 2019-03-15 20:46:19
Wiki:window-functions
Context
2019-03-16
10:15
In order to identify the first row of each partition, check if the rowid in the ephemeral table is 1 instead of using a dedicated flag register. check-in: f2d5f7a24c user: dan tags: window-functions
2019-03-15
20:46
Implement the EXCLUDE clause for window frames. check-in: 9b43c3ee2e user: dan tags: window-functions
2019-03-14
20:53
Parse EXCLUDE clauses in window frames. They do not yet work. check-in: d03c7533a1 user: dan tags: window-functions
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/window.c.

238
239
240
241
242
243
244































245
246
247
248
249
250
251
...
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
...
617
618
619
620
621
622
623

624
625
626
627
628
629
630
....
1308
1309
1310
1311
1312
1313
1314

1315



1316
1317
1318
1319
1320
1321
1322
....
1364
1365
1366
1367
1368
1369
1370


















































1371
1372
1373
1374
1375
1376
1377
1378


1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
....
1422
1423
1424
1425
1426
1427
1428










































































1429
1430
1431
1432
1433
1434
1435
....
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449





1450

1451
1452
1453
1454
1455

1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521

1522
1523
1524
1525
1526
1527
1528
1529
....
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
....
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
....
1845
1846
1847
1848
1849
1850
1851

1852
1853
1854
1855
1856
1857
1858
....
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
    sqlite3_result_value(pCtx, p->pValue);
    sqlite3_value_free(p->pValue);
    p->pValue = 0;
  }
}
#define nth_valueInvFunc noopStepFunc
































/*
** Implementation of built-in window function rank(). Assumes that
** the window frame has been set to:
**
**   RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW 
*/
static void rankStepFunc(
................................................................................
    WINDOWFUNCX(dense_rank, 0, 0),
    WINDOWFUNCX(rank, 0, 0),
    WINDOWFUNCALL(percent_rank, 0, 0),
    WINDOWFUNCALL(cume_dist, 0, 0),
    WINDOWFUNCALL(ntile, 1, 0),
    WINDOWFUNCALL(last_value, 1, 0),
    WINDOWFUNCALL(nth_value, 2, 0),
    WINDOWFUNCNOOP(first_value, 1, 0),
    WINDOWFUNCNOOP(lead, 1, 0),
    WINDOWFUNCNOOP(lead, 2, 0),
    WINDOWFUNCNOOP(lead, 3, 0),
    WINDOWFUNCNOOP(lag, 1, 0),
    WINDOWFUNCNOOP(lag, 2, 0),
    WINDOWFUNCNOOP(lag, 3, 0),
  };
................................................................................
    pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0);
    pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0);
    pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0);
    pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);
    pWin->eStart = p->eStart;
    pWin->eEnd = p->eEnd;
    pWin->eType = p->eType;

  }else{
    sqlite3WindowChain(pParse, pWin, pList);
  }
  if( (pWin->eType==TK_RANGE)
   && (pWin->pStart || pWin->pEnd) 
   && (pWin->pOrderBy==0 || pWin->pOrderBy->nExpr!=1)
  ){
................................................................................
  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    FuncDef *pFunc = pWin->pFunc;
    int regArg;
    int nArg = windowArgCount(pWin);
    int i;

    for(i=0; i<nArg; i++){

      sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);



    }
    regArg = reg;

    if( pMWin->regStartRowid==0
     && (pFunc->funcFlags & SQLITE_FUNC_MINMAX) 
     && (pWin->eStart!=TK_UNBOUNDED)
    ){
................................................................................
                        bInverse, regArg, pWin->regAccum);
      sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF);
      sqlite3VdbeChangeP5(v, (u8)nArg);
      if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
    }
  }
}



















































/*
** Generate VM code to invoke either xValue() (bFin==0) or xFinalize()
** (bFin==1) for each window function in the linked list starting at
** pMWin. Or, for built-in window-functions that do not use the standard
** API, generate the equivalent VM code.
*/
static void windowAggFinal(Parse *pParse, Window *pMWin, int regArg, int bFin){


  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;

  if( pMWin->regStartRowid ){
    int addrNext;
    int regRowid = sqlite3GetTempReg(pParse);
    assert( pMWin->csrApp );
    for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
    }
    sqlite3VdbeAddOp3(v, OP_SeekGE, pMWin->csrApp, 0, pMWin->regStartRowid);
    addrNext = sqlite3VdbeCurrentAddr(v);
    sqlite3VdbeAddOp2(v, OP_Rowid, pMWin->csrApp, regRowid);
    sqlite3VdbeAddOp3(v, OP_Gt, pMWin->regEndRowid, 0, regRowid);
    windowAggStep(pParse, pMWin, pMWin->csrApp, 0, regArg);
    sqlite3VdbeAddOp2(v, OP_Next, pMWin->csrApp, addrNext);
    sqlite3VdbeJumpHere(v, addrNext-1);
    sqlite3VdbeJumpHere(v, addrNext+1);
    sqlite3ReleaseTempReg(pParse, regRowid);
  }

  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    if( pMWin->regStartRowid==0
     && (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX) 
     && (pWin->eStart!=TK_UNBOUNDED)
    ){
      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
      sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
................................................................................
      }else{
        sqlite3VdbeAddOp3(v, OP_AggValue,pWin->regAccum,nArg,pWin->regResult);
        sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
      }
    }
  }
}











































































/*
** Invoke the sub-routine at regGosub (generated by code in select.c) to
** return the current row of Window.iEphCsr. If all window functions are
** aggregate window functions that use the standard API, a single
** OP_Gosub instruction is all that this routine generates. Extra VM code
** for per-row processing is only generated for the following built-in window
................................................................................
** functions:
**
**   nth_value()
**   first_value()
**   lag()
**   lead()
*/
static void windowReturnOneRow(
  Parse *pParse,
  Window *pMWin,
  int regGosub,
  int addrGosub
){
  Vdbe *v = sqlite3GetVdbe(pParse);





  Window *pWin;

  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    FuncDef *pFunc = pWin->pFunc;
    if( pFunc->zName==nth_valueName
     || pFunc->zName==first_valueName
    ){

      int lbl = sqlite3VdbeMakeLabel(pParse);
      int tmpReg = sqlite3GetTempReg(pParse);
      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);

      if( pFunc->zName==nth_valueName ){
        sqlite3VdbeAddOp3(v, OP_Column,pMWin->iEphCsr,pWin->iArgCol+1,tmpReg);
        windowCheckValue(pParse, tmpReg, 2);
      }else{
        sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg);
      }
      if( pWin->eExclude==0 ){
        int csr = pWin->csrApp;
        sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg);
        sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg);
        VdbeCoverageNeverNull(v);
        sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg);
        VdbeCoverageNeverTaken(v);
        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
      }else{
        int regRowid = sqlite3GetTempReg(pParse);
        int csr = pMWin->csrApp;
        int addrNext;
        sqlite3VdbeAddOp3(v, OP_IfPos, tmpReg, sqlite3VdbeCurrentAddr(v)+1, 1);
        sqlite3VdbeAddOp3(v, OP_SeekGE, csr, lbl, pMWin->regStartRowid);
        addrNext = sqlite3VdbeAddOp2(v, OP_Rowid, csr, regRowid);
        sqlite3VdbeAddOp3(v, OP_Gt, pMWin->regEndRowid, lbl, regRowid);
        sqlite3VdbeAddOp3(v, OP_IfPos, tmpReg, sqlite3VdbeCurrentAddr(v)+3, 1);
        sqlite3VdbeAddOp3(v, OP_Column, csr, pMWin->iArgCol, pWin->regResult);
        sqlite3VdbeAddOp2(v, OP_Goto, 0, lbl);
        sqlite3VdbeAddOp2(v, OP_Next, csr, addrNext);
        sqlite3ReleaseTempReg(pParse, regRowid);
      }
      sqlite3VdbeResolveLabel(v, lbl);
      sqlite3ReleaseTempReg(pParse, tmpReg);
    }
    else if( pFunc->zName==leadName || pFunc->zName==lagName ){
      int nArg = pWin->pOwner->x.pList->nExpr;
      int csr = pWin->csrApp;
      int lbl = sqlite3VdbeMakeLabel(pParse);
      int tmpReg = sqlite3GetTempReg(pParse);
      int iEph = pMWin->iEphCsr;

      if( nArg<3 ){
        sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
      }else{
        sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+2, pWin->regResult);
      }
      sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg);
      if( nArg<2 ){
        int val = (pFunc->zName==leadName ? 1 : -1);
        sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val);
      }else{
        int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract);
        int tmpReg2 = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2);
        sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg);
        sqlite3ReleaseTempReg(pParse, tmpReg2);
      }

      sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg);
      VdbeCoverage(v);
      sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
      sqlite3VdbeResolveLabel(v, lbl);
      sqlite3ReleaseTempReg(pParse, tmpReg);
    }
  }

  sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
}

/*
** Generate code to set the accumulator register for each window function
** in the linked list passed as the second argument to NULL. And perform
** any equivalent initialization required by any built-in window functions
** in the list.
................................................................................
    VdbeCoverageEqNe(v);
    sqlite3VdbeAddOp3(v, OP_Copy, regNew, regOld, nVal-1);
  }else{
    sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
  }
}

typedef struct WindowCodeArg WindowCodeArg;
typedef struct WindowCsrAndReg WindowCsrAndReg;
struct WindowCsrAndReg {
  int csr;
  int reg;
};

struct WindowCodeArg {
  Parse *pParse;
  Window *pMWin;
  Vdbe *pVdbe;
  int regGosub;
  int addrGosub;
  int regArg;
  int eDelete;

  WindowCsrAndReg start;
  WindowCsrAndReg current;
  WindowCsrAndReg end;
};

/*
** Values that may be passed as the second argument to windowCodeOp().
*/
#define WINDOW_RETURN_ROW 1
#define WINDOW_AGGINVERSE 2
#define WINDOW_AGGSTEP    3

/*
** Generate VM code to read the window frames peer values from cursor csr into
** an array of registers starting at reg.
*/
static void windowReadPeerValues(
  WindowCodeArg *p,
  int csr,
  int reg
){
  Window *pMWin = p->pMWin;
  ExprList *pOrderBy = pMWin->pOrderBy;
  if( pOrderBy ){
    Vdbe *v = sqlite3GetVdbe(p->pParse);
    ExprList *pPart = pMWin->pPartition;
    int iColOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);
    int i;
    for(i=0; i<pOrderBy->nExpr; i++){
      sqlite3VdbeAddOp3(v, OP_Column, csr, iColOff+i, reg+i);
    }
  }
}

/*
** This function is called as part of generating VM programs for RANGE
** offset PRECEDING/FOLLOWING frame boundaries. It generates code equivalent
** to:
**
**   if( csr1.peerVal + regVal >= csr2.peerVal ) goto lbl;
**   if( csr1.rowid >= csr2.rowid ) goto lbl;
................................................................................

    }else{
      addrIf = sqlite3VdbeAddOp3(v, OP_IfPos, regCountdown, 0, 1);
    }
  }

  if( op==WINDOW_RETURN_ROW ){
    windowAggFinal(pParse, pMWin, p->regArg, 0);
  }
  addrContinue = sqlite3VdbeCurrentAddr(v);
  switch( op ){
    case WINDOW_RETURN_ROW:
      csr = p->current.csr;
      reg = p->current.reg;
      windowReturnOneRow(pParse, pMWin, p->regGosub, p->addrGosub);
      break;

    case WINDOW_AGGINVERSE:
      csr = p->start.csr;
      reg = p->start.reg;
      if( pMWin->regStartRowid ){
        assert( pMWin->regEndRowid );
................................................................................
      pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
      pNew->pFunc = p->pFunc;
      pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
      pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
      pNew->eType = p->eType;
      pNew->eEnd = p->eEnd;
      pNew->eStart = p->eStart;

      pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
      pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
      pNew->pOwner = pOwner;
    }
  }
  return pNew;
}
................................................................................
    sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
    windowCheckValue(pParse, regEnd, 1 + (pMWin->eType==TK_RANGE ? 3 : 0));
  }

  if( pMWin->eStart==pMWin->eEnd && regStart && regEnd ){
    int op = ((pMWin->eStart==TK_FOLLOWING) ? OP_Ge : OP_Le);
    int addrGe = sqlite3VdbeAddOp3(v, op, regStart, 0, regEnd);
    windowAggFinal(pParse, pMWin, s.regArg, 0);
    sqlite3VdbeAddOp2(v, OP_Rewind, s.current.csr, 1);
    windowReturnOneRow(pParse, pMWin, regGosub, addrGosub);
    sqlite3VdbeAddOp1(v, OP_ResetSorter, s.current.csr);
    sqlite3VdbeAddOp2(v, OP_Goto, 0, lblWhereEnd);
    sqlite3VdbeJumpHere(v, addrGe);
  }
  if( pMWin->eStart==TK_FOLLOWING && pMWin->eType!=TK_RANGE && regEnd ){
    assert( pMWin->eEnd==TK_FOLLOWING );
    sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regStart);







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







>







 







>
|
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







|
>
>



<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
<
|
<
<
<
|
>
>
>
>
>
|
>
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<
<






<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|






|







 







>







 







|

|







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
...
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
...
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
....
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
....
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469


















1470
1471
1472
1473
1474
1475
1476
....
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
....
1580
1581
1582
1583
1584
1585
1586
1587

1588



1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612


1613
1614
1615
1616
1617
1618














1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
....
1736
1737
1738
1739
1740
1741
1742


















































1743
1744
1745
1746
1747
1748
1749
....
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
....
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
....
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
    sqlite3_result_value(pCtx, p->pValue);
    sqlite3_value_free(p->pValue);
    p->pValue = 0;
  }
}
#define nth_valueInvFunc noopStepFunc

static void first_valueStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
  struct NthValueCtx *p;
  p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p && p->pValue==0 ){
    p->pValue = sqlite3_value_dup(apArg[0]);
  }
  UNUSED_PARAMETER(nArg);
  UNUSED_PARAMETER(apArg);
}
static void first_valueValueFunc(sqlite3_context *pCtx){
  struct NthValueCtx *p;
  p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p && p->pValue ){
    sqlite3_result_value(pCtx, p->pValue);
  }
}
static void first_valueFinalizeFunc(sqlite3_context *pCtx){
  struct NthValueCtx *p;
  p = (struct NthValueCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p && p->pValue ){
    sqlite3_result_value(pCtx, p->pValue);
    sqlite3_value_free(p->pValue);
    p->pValue = 0;
  }
}
#define first_valueInvFunc noopStepFunc

/*
** Implementation of built-in window function rank(). Assumes that
** the window frame has been set to:
**
**   RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW 
*/
static void rankStepFunc(
................................................................................
    WINDOWFUNCX(dense_rank, 0, 0),
    WINDOWFUNCX(rank, 0, 0),
    WINDOWFUNCALL(percent_rank, 0, 0),
    WINDOWFUNCALL(cume_dist, 0, 0),
    WINDOWFUNCALL(ntile, 1, 0),
    WINDOWFUNCALL(last_value, 1, 0),
    WINDOWFUNCALL(nth_value, 2, 0),
    WINDOWFUNCALL(first_value, 1, 0),
    WINDOWFUNCNOOP(lead, 1, 0),
    WINDOWFUNCNOOP(lead, 2, 0),
    WINDOWFUNCNOOP(lead, 3, 0),
    WINDOWFUNCNOOP(lag, 1, 0),
    WINDOWFUNCNOOP(lag, 2, 0),
    WINDOWFUNCNOOP(lag, 3, 0),
  };
................................................................................
    pWin->pPartition = sqlite3ExprListDup(pParse->db, p->pPartition, 0);
    pWin->pOrderBy = sqlite3ExprListDup(pParse->db, p->pOrderBy, 0);
    pWin->pStart = sqlite3ExprDup(pParse->db, p->pStart, 0);
    pWin->pEnd = sqlite3ExprDup(pParse->db, p->pEnd, 0);
    pWin->eStart = p->eStart;
    pWin->eEnd = p->eEnd;
    pWin->eType = p->eType;
    pWin->eExclude = p->eExclude;
  }else{
    sqlite3WindowChain(pParse, pWin, pList);
  }
  if( (pWin->eType==TK_RANGE)
   && (pWin->pStart || pWin->pEnd) 
   && (pWin->pOrderBy==0 || pWin->pOrderBy->nExpr!=1)
  ){
................................................................................
  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    FuncDef *pFunc = pWin->pFunc;
    int regArg;
    int nArg = windowArgCount(pWin);
    int i;

    for(i=0; i<nArg; i++){
      if( i!=1 || pFunc->zName!=nth_valueName ){
        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
      }else{
        sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+i, reg+i);
      }
    }
    regArg = reg;

    if( pMWin->regStartRowid==0
     && (pFunc->funcFlags & SQLITE_FUNC_MINMAX) 
     && (pWin->eStart!=TK_UNBOUNDED)
    ){
................................................................................
                        bInverse, regArg, pWin->regAccum);
      sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF);
      sqlite3VdbeChangeP5(v, (u8)nArg);
      if( addrIf ) sqlite3VdbeJumpHere(v, addrIf);
    }
  }
}

typedef struct WindowCodeArg WindowCodeArg;
typedef struct WindowCsrAndReg WindowCsrAndReg;
struct WindowCsrAndReg {
  int csr;
  int reg;
};

struct WindowCodeArg {
  Parse *pParse;
  Window *pMWin;
  Vdbe *pVdbe;
  int regGosub;
  int addrGosub;
  int regArg;
  int eDelete;

  WindowCsrAndReg start;
  WindowCsrAndReg current;
  WindowCsrAndReg end;
};

/*
** Values that may be passed as the second argument to windowCodeOp().
*/
#define WINDOW_RETURN_ROW 1
#define WINDOW_AGGINVERSE 2
#define WINDOW_AGGSTEP    3

/*
** Generate VM code to read the window frames peer values from cursor csr into
** an array of registers starting at reg.
*/
static void windowReadPeerValues(
  WindowCodeArg *p,
  int csr,
  int reg
){
  Window *pMWin = p->pMWin;
  ExprList *pOrderBy = pMWin->pOrderBy;
  if( pOrderBy ){
    Vdbe *v = sqlite3GetVdbe(p->pParse);
    ExprList *pPart = pMWin->pPartition;
    int iColOff = pMWin->nBufferCol + (pPart ? pPart->nExpr : 0);
    int i;
    for(i=0; i<pOrderBy->nExpr; i++){
      sqlite3VdbeAddOp3(v, OP_Column, csr, iColOff+i, reg+i);
    }
  }
}

/*
** Generate VM code to invoke either xValue() (bFin==0) or xFinalize()
** (bFin==1) for each window function in the linked list starting at
** pMWin. Or, for built-in window-functions that do not use the standard
** API, generate the equivalent VM code.
*/
static void windowAggFinal(WindowCodeArg *p, int bFin){
  Parse *pParse = p->pParse;
  Window *pMWin = p->pMWin;
  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;



















  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    if( pMWin->regStartRowid==0
     && (pWin->pFunc->funcFlags & SQLITE_FUNC_MINMAX) 
     && (pWin->eStart!=TK_UNBOUNDED)
    ){
      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
      sqlite3VdbeAddOp1(v, OP_Last, pWin->csrApp);
................................................................................
      }else{
        sqlite3VdbeAddOp3(v, OP_AggValue,pWin->regAccum,nArg,pWin->regResult);
        sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
      }
    }
  }
}

static void windowFullScan(WindowCodeArg *p){
  Window *pWin;
  Parse *pParse = p->pParse;
  Window *pMWin = p->pMWin;
  Vdbe *v = p->pVdbe;

  int regCRowid = 0;              /* Current rowid value */
  int regCPeer = 0;               /* Current peer values */
  int regRowid = 0;               /* AggStep rowid value */
  int regPeer = 0;                /* AggStep peer values */

  int nPeer;
  int lblNext;
  int lblBrk;
  int addrNext;
  int csr = pMWin->csrApp;

  nPeer = (pMWin->pOrderBy ? pMWin->pOrderBy->nExpr : 0);

  lblNext = sqlite3VdbeMakeLabel(pParse);
  lblBrk = sqlite3VdbeMakeLabel(pParse);

  regCRowid = sqlite3GetTempReg(pParse);
  regRowid = sqlite3GetTempReg(pParse);
  if( nPeer ){
    regCPeer = sqlite3GetTempRange(pParse, nPeer);
    regPeer = sqlite3GetTempRange(pParse, nPeer);
  }

  sqlite3VdbeAddOp2(v, OP_Rowid, pMWin->iEphCsr, regCRowid);
  windowReadPeerValues(p, pMWin->iEphCsr, regCPeer);

  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
  }

  sqlite3VdbeAddOp3(v, OP_SeekGE, csr, lblBrk, pMWin->regStartRowid);
  addrNext = sqlite3VdbeCurrentAddr(v);
  sqlite3VdbeAddOp2(v, OP_Rowid, csr, regRowid);
  sqlite3VdbeAddOp3(v, OP_Gt, pMWin->regEndRowid, lblBrk, regRowid);
  if( pMWin->eExclude==TK_CURRENT ){
    sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, lblNext, regRowid);
  }else if( pMWin->eExclude!=TK_NO ){
    int addr;
    int addrEq = 0;;
    KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pMWin->pOrderBy,0,0);
    if( pMWin->eExclude==TK_TIES ){
      addrEq = sqlite3VdbeAddOp3(v, OP_Eq, regCRowid, lblNext, regRowid);
    }
    windowReadPeerValues(p, csr, regPeer);
    sqlite3VdbeAddOp3(v, OP_Compare, regPeer, regCPeer, nPeer);
    sqlite3VdbeAppendP4(v, (void*)pKeyInfo, P4_KEYINFO);
    addr = sqlite3VdbeCurrentAddr(v)+1;
    sqlite3VdbeAddOp3(v, OP_Jump, addr, lblNext, addr);
    VdbeCoverageEqNe(v);
    if( addrEq ) sqlite3VdbeJumpHere(v, addrEq);
  }

  windowAggStep(pParse, pMWin, csr, 0, p->regArg);

  sqlite3VdbeResolveLabel(v, lblNext);
  sqlite3VdbeAddOp2(v, OP_Next, csr, addrNext);
  sqlite3VdbeJumpHere(v, addrNext-1);
  sqlite3VdbeJumpHere(v, addrNext+1);
  sqlite3ReleaseTempReg(pParse, regRowid);
  sqlite3ReleaseTempReg(pParse, regCRowid);
  if( nPeer ){
    sqlite3ReleaseTempRange(pParse, regPeer, nPeer);
    sqlite3ReleaseTempRange(pParse, regCPeer, nPeer);
  }

  windowAggFinal(p, 1);
}

/*
** Invoke the sub-routine at regGosub (generated by code in select.c) to
** return the current row of Window.iEphCsr. If all window functions are
** aggregate window functions that use the standard API, a single
** OP_Gosub instruction is all that this routine generates. Extra VM code
** for per-row processing is only generated for the following built-in window
................................................................................
** functions:
**
**   nth_value()
**   first_value()
**   lag()
**   lead()
*/
static void windowReturnOneRow(WindowCodeArg *p){

  Window *pMWin = p->pMWin;



  Vdbe *v = p->pVdbe;

  if( pMWin->regStartRowid ){
    windowFullScan(p);
  }else{
    Parse *pParse = p->pParse;
    Window *pWin;

    for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
      FuncDef *pFunc = pWin->pFunc;
      if( pFunc->zName==nth_valueName
       || pFunc->zName==first_valueName
      ){
        int csr = pWin->csrApp;
        int lbl = sqlite3VdbeMakeLabel(pParse);
        int tmpReg = sqlite3GetTempReg(pParse);
        sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
  
        if( pFunc->zName==nth_valueName ){
          sqlite3VdbeAddOp3(v, OP_Column,pMWin->iEphCsr,pWin->iArgCol+1,tmpReg);
          windowCheckValue(pParse, tmpReg, 2);
        }else{
          sqlite3VdbeAddOp2(v, OP_Integer, 1, tmpReg);
        }


        sqlite3VdbeAddOp3(v, OP_Add, tmpReg, pWin->regApp, tmpReg);
        sqlite3VdbeAddOp3(v, OP_Gt, pWin->regApp+1, lbl, tmpReg);
        VdbeCoverageNeverNull(v);
        sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, 0, tmpReg);
        VdbeCoverageNeverTaken(v);
        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);














        sqlite3VdbeResolveLabel(v, lbl);
        sqlite3ReleaseTempReg(pParse, tmpReg);
      }
      else if( pFunc->zName==leadName || pFunc->zName==lagName ){
        int nArg = pWin->pOwner->x.pList->nExpr;
        int csr = pWin->csrApp;
        int lbl = sqlite3VdbeMakeLabel(pParse);
        int tmpReg = sqlite3GetTempReg(pParse);
        int iEph = pMWin->iEphCsr;
  
        if( nArg<3 ){
          sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
        }else{
          sqlite3VdbeAddOp3(v, OP_Column, iEph,pWin->iArgCol+2,pWin->regResult);
        }
        sqlite3VdbeAddOp2(v, OP_Rowid, iEph, tmpReg);
        if( nArg<2 ){
          int val = (pFunc->zName==leadName ? 1 : -1);
          sqlite3VdbeAddOp2(v, OP_AddImm, tmpReg, val);
        }else{
          int op = (pFunc->zName==leadName ? OP_Add : OP_Subtract);
          int tmpReg2 = sqlite3GetTempReg(pParse);
          sqlite3VdbeAddOp3(v, OP_Column, iEph, pWin->iArgCol+1, tmpReg2);
          sqlite3VdbeAddOp3(v, op, tmpReg2, tmpReg, tmpReg);
          sqlite3ReleaseTempReg(pParse, tmpReg2);
        }
  
        sqlite3VdbeAddOp3(v, OP_SeekRowid, csr, lbl, tmpReg);
        VdbeCoverage(v);
        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol, pWin->regResult);
        sqlite3VdbeResolveLabel(v, lbl);
        sqlite3ReleaseTempReg(pParse, tmpReg);
      }
    }
  }
  sqlite3VdbeAddOp2(v, OP_Gosub, p->regGosub, p->addrGosub);
}

/*
** Generate code to set the accumulator register for each window function
** in the linked list passed as the second argument to NULL. And perform
** any equivalent initialization required by any built-in window functions
** in the list.
................................................................................
    VdbeCoverageEqNe(v);
    sqlite3VdbeAddOp3(v, OP_Copy, regNew, regOld, nVal-1);
  }else{
    sqlite3VdbeAddOp2(v, OP_Goto, 0, addr);
  }
}



















































/*
** This function is called as part of generating VM programs for RANGE
** offset PRECEDING/FOLLOWING frame boundaries. It generates code equivalent
** to:
**
**   if( csr1.peerVal + regVal >= csr2.peerVal ) goto lbl;
**   if( csr1.rowid >= csr2.rowid ) goto lbl;
................................................................................

    }else{
      addrIf = sqlite3VdbeAddOp3(v, OP_IfPos, regCountdown, 0, 1);
    }
  }

  if( op==WINDOW_RETURN_ROW ){
    windowAggFinal(p, 0);
  }
  addrContinue = sqlite3VdbeCurrentAddr(v);
  switch( op ){
    case WINDOW_RETURN_ROW:
      csr = p->current.csr;
      reg = p->current.reg;
      windowReturnOneRow(p);
      break;

    case WINDOW_AGGINVERSE:
      csr = p->start.csr;
      reg = p->start.reg;
      if( pMWin->regStartRowid ){
        assert( pMWin->regEndRowid );
................................................................................
      pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
      pNew->pFunc = p->pFunc;
      pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
      pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
      pNew->eType = p->eType;
      pNew->eEnd = p->eEnd;
      pNew->eStart = p->eStart;
      pNew->eExclude = p->eExclude;
      pNew->pStart = sqlite3ExprDup(db, p->pStart, 0);
      pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0);
      pNew->pOwner = pOwner;
    }
  }
  return pNew;
}
................................................................................
    sqlite3ExprCode(pParse, pMWin->pEnd, regEnd);
    windowCheckValue(pParse, regEnd, 1 + (pMWin->eType==TK_RANGE ? 3 : 0));
  }

  if( pMWin->eStart==pMWin->eEnd && regStart && regEnd ){
    int op = ((pMWin->eStart==TK_FOLLOWING) ? OP_Ge : OP_Le);
    int addrGe = sqlite3VdbeAddOp3(v, op, regStart, 0, regEnd);
    windowAggFinal(&s, 0);
    sqlite3VdbeAddOp2(v, OP_Rewind, s.current.csr, 1);
    windowReturnOneRow(&s);
    sqlite3VdbeAddOp1(v, OP_ResetSorter, s.current.csr);
    sqlite3VdbeAddOp2(v, OP_Goto, 0, lblWhereEnd);
    sqlite3VdbeJumpHere(v, addrGe);
  }
  if( pMWin->eStart==TK_FOLLOWING && pMWin->eType!=TK_RANGE && regEnd ){
    assert( pMWin->eEnd==TK_FOLLOWING );
    sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regStart);

Changes to test/window3.tcl.

68
69
70
71
72
73
74





75
76
77
78
79
80
81
  11 "ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING"
  12 "ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING"
  13 "ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING"
  14 "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
  15 "ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING"
  16 "ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING"
  17 "ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING"





} {
  execsql_test 1.$tn.2.1 "SELECT max(b) OVER ( ORDER BY a $window ) FROM t2"
  execsql_test 1.$tn.2.2 "SELECT min(b) OVER ( ORDER BY a $window ) FROM t2"

  execsql_test 1.$tn.3.1 "
    SELECT row_number() OVER ( ORDER BY a $window ) FROM t2
  "







>
>
>
>
>







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  11 "ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING"
  12 "ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING"
  13 "ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING"
  14 "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING"
  15 "ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING"
  16 "ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING"
  17 "ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING"

  18 "ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING EXCLUDE CURRENT ROW"
  19 "ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING EXCLUDE TIES"
  20 "ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING EXCLUDE GROUP"

} {
  execsql_test 1.$tn.2.1 "SELECT max(b) OVER ( ORDER BY a $window ) FROM t2"
  execsql_test 1.$tn.2.2 "SELECT min(b) OVER ( ORDER BY a $window ) FROM t2"

  execsql_test 1.$tn.3.1 "
    SELECT row_number() OVER ( ORDER BY a $window ) FROM t2
  "

Changes to test/window3.test.

cannot compute difference between binary files

Changes to test/window8.tcl.

83
84
85
86
87
88
89









90
91
92
93
94
95
96
...
104
105
106
107
108
109
110


111

112
113
114
115
116
117
118
  "
  execsql_test 1.$tn.4 "
    SELECT a, b, max(c) OVER (ORDER BY a,b $frame) FROM t3 ORDER BY 1, 2, 3;
  "
  execsql_test 1.$tn.5 "
    SELECT a, b, min(c) OVER (ORDER BY a,b $frame) FROM t3 ORDER BY 1, 2, 3;
  "









}


foreach {tn ex} {
  1  { EXCLUDE NO OTHERS }
  2  { EXCLUDE CURRENT ROW }
  3  { EXCLUDE GROUP }
................................................................................
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING $ex
    )
  "

  execsql_test 2.$tn.2 "
    SELECT nth_value(c, 14) OVER win 
    FROM t3


    WINDOW win AS (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING $ex)

  "
}

==========

execsql_test 3.0 {
  DROP TABLE IF EXISTS t1;







>
>
>
>
>
>
>
>
>







 







>
>
|
>







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  "
  execsql_test 1.$tn.4 "
    SELECT a, b, max(c) OVER (ORDER BY a,b $frame) FROM t3 ORDER BY 1, 2, 3;
  "
  execsql_test 1.$tn.5 "
    SELECT a, b, min(c) OVER (ORDER BY a,b $frame) FROM t3 ORDER BY 1, 2, 3;
  "

  set f2 "$frame EXCLUDE CURRENT ROW"

  execsql_test 1.$tn.6 "
    SELECT a, b, sum(c) OVER (ORDER BY a $f2) FROM t3 ORDER BY 1, 2, 3;
  "
  execsql_test 1.$tn.7 "
    SELECT a, b, sum(c) OVER (ORDER BY a,b $f2) FROM t3 ORDER BY 1, 2, 3;
  "
}


foreach {tn ex} {
  1  { EXCLUDE NO OTHERS }
  2  { EXCLUDE CURRENT ROW }
  3  { EXCLUDE GROUP }
................................................................................
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING $ex
    )
  "

  execsql_test 2.$tn.2 "
    SELECT nth_value(c, 14) OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING $ex
    )
  "
}

==========

execsql_test 3.0 {
  DROP TABLE IF EXISTS t1;

Changes to test/window8.test.

69
70
71
72
73
74
75








76
77
78
79
80
81
82
..
89
90
91
92
93
94
95








96
97
98
99
100
101
102
...
109
110
111
112
113
114
115








116
117
118
119
120
121
122
...
129
130
131
132
133
134
135








136
137
138
139
140
141
142
...
149
150
151
152
153
154
155








156
157
158
159
160
161
162
...
169
170
171
172
173
174
175








176
177
178
179
180
181
182
...
189
190
191
192
193
194
195








196
197
198
199
200
201
202
...
209
210
211
212
213
214
215








216
217
218
219
220
221
222
...
229
230
231
232
233
234
235








236
237
238
239
240
241
242
...
249
250
251
252
253
254
255








256
257
258
259
260
261
262
...
269
270
271
272
273
274
275








276
277
278
279
280
281
282
...
289
290
291
292
293
294
295








296
297
298
299
300
301
302
...
309
310
311
312
313
314
315








316
317
318
319
320
321
322
...
329
330
331
332
333
334
335








336
337
338
339
340
341
342
...
349
350
351
352
353
354
355








356
357
358
359
360
361
362
...
369
370
371
372
373
374
375








376
377
378
379
380
381
382
...
389
390
391
392
393
394
395








396
397
398
399
400
401
402
...
409
410
411
412
413
414
415








416
417
418
419
420
421
422
...
429
430
431
432
433
434
435








436
437
438
439
440
441
442
443
444
445
446
447


448
449


450
451
452
453
454
455
456
457
458
459
460
461
462


463
464


465
466
467
468
469
470
471
472
473
474
475
476
477


478
479


480
481
482
483
484
485
486
487
488
489
490
491
492


493
494


495
496
497
498
499
500
501
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 934   CC aa 934   CC aa 934   CC aa 934   CC bb 934   CC bb 934   DD aa 934   DD aa 934   DD aa 934   DD bb 934   DD bb 934   DD bb 934   DD bb 934   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   GG aa 959   GG aa 959   GG aa 959   GG aa 959   GG bb 959   GG bb 959   GG bb 959   GG bb 959   HH aa 959   HH aa 959   HH aa 959   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ bb 979   JJ bb 979   JJ bb 979   JJ bb 979}

do_execsql_test 1.1.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 223   CC aa 223   CC aa 223   CC aa 223   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 158   EE aa 158   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   II aa 102   II aa 102   II bb 102   II bb 102   II bb 102   II bb 102   II bb 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ bb 102   JJ bb 102   JJ bb 102   JJ bb 102}









do_execsql_test 1.2.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 15147   CC bb 15147   DD aa 19179   DD aa 19179   DD aa 19179   DD bb 19179   DD bb 19179   DD bb 19179   DD bb 19179   EE aa 21718   EE aa 21718   EE bb 21718   EE bb 21718   EE bb 21718   FF aa 27386   FF aa 27386   FF aa 27386   FF aa 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   GG aa 31854   GG aa 31854   GG aa 31854   GG aa 31854   GG bb 31854   GG bb 31854   GG bb 31854   GG bb 31854   HH aa 37297   HH aa 37297   HH aa 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   II aa 40937   II aa 40937   II bb 40937   II bb 40937   II bb 40937   II bb 40937   II bb 40937   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}

do_execsql_test 1.2.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 13979   CC aa 13979   CC aa 13979   CC aa 13979   CC bb 15147   CC bb 15147   DD aa 16472   DD aa 16472   DD aa 16472   DD bb 19179   DD bb 19179   DD bb 19179   DD bb 19179   EE aa 20069   EE aa 20069   EE bb 21718   EE bb 21718   EE bb 21718   FF aa 23881   FF aa 23881   FF aa 23881   FF aa 23881   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   GG aa 28983   GG aa 28983   GG aa 28983   GG aa 28983   GG bb 31854   GG bb 31854   GG bb 31854   GG bb 31854   HH aa 34103   HH aa 34103   HH aa 34103   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   II aa 38347   II aa 38347   II bb 40937   II bb 40937   II bb 40937   II bb 40937   II bb 40937   JJ aa 42951   JJ aa 42951   JJ aa 42951   JJ aa 42951   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 934   CC aa 934   CC aa 934   CC aa 934   CC bb 934   CC bb 934   DD aa 934   DD aa 934   DD aa 934   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   GG aa 959   GG aa 959   GG aa 959   GG aa 959   GG bb 959   GG bb 959   GG bb 959   GG bb 959   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ bb 979   JJ bb 979   JJ bb 979   JJ bb 979}

do_execsql_test 1.2.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   II aa 102   II aa 102   II bb 102   II bb 102   II bb 102   II bb 102   II bb 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ bb 102   JJ bb 102   JJ bb 102   JJ bb 102}









do_execsql_test 1.3.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 12025   AA aa 12025   AA aa 12025   AA aa 12025   AA bb 12025   AA bb 12025   AA bb 12025   AA bb 12025   BB aa 15147   BB aa 15147   BB aa 15147   BB aa 15147   BB aa 15147   BB aa 15147   BB bb 15147   BB bb 15147   BB bb 15147   BB bb 15147   BB bb 15147   BB bb 15147   CC aa 19179   CC aa 19179   CC aa 19179   CC aa 19179   CC bb 19179   CC bb 19179   DD aa 21718   DD aa 21718   DD aa 21718   DD bb 21718   DD bb 21718   DD bb 21718   DD bb 21718   EE aa 27386   EE aa 27386   EE bb 27386   EE bb 27386   EE bb 27386   FF aa 31854   FF aa 31854   FF aa 31854   FF aa 31854   FF bb 31854   FF bb 31854   FF bb 31854   FF bb 31854   FF bb 31854   FF bb 31854   GG aa 37297   GG aa 37297   GG aa 37297   GG aa 37297   GG bb 37297   GG bb 37297   GG bb 37297   GG bb 37297   HH aa 40937   HH aa 40937   HH aa 40937   HH bb 40937   HH bb 40937   HH bb 40937   HH bb 40937   HH bb 40937   HH bb 40937   II aa 44737   II aa 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}

do_execsql_test 1.3.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 7558   AA bb 7558   AA bb 7558   AA bb 7558   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 13979   BB bb 13979   BB bb 13979   BB bb 13979   BB bb 13979   BB bb 13979   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 16472   CC bb 16472   DD aa 19179   DD aa 19179   DD aa 19179   DD bb 20069   DD bb 20069   DD bb 20069   DD bb 20069   EE aa 21718   EE aa 21718   EE bb 23881   EE bb 23881   EE bb 23881   FF aa 27386   FF aa 27386   FF aa 27386   FF aa 27386   FF bb 28983   FF bb 28983   FF bb 28983   FF bb 28983   FF bb 28983   FF bb 28983   GG aa 31854   GG aa 31854   GG aa 31854   GG aa 31854   GG bb 34103   GG bb 34103   GG bb 34103   GG bb 34103   HH aa 37297   HH aa 37297   HH aa 37297   HH bb 38347   HH bb 38347   HH bb 38347   HH bb 38347   HH bb 38347   HH bb 38347   II aa 40937   II aa 40937   II bb 42951   II bb 42951   II bb 42951   II bb 42951   II bb 42951   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 934   CC aa 934   CC aa 934   CC aa 934   CC bb 934   CC bb 934   DD aa 959   DD aa 959   DD aa 959   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   GG aa 959   GG aa 959   GG aa 959   GG aa 959   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ bb 979   JJ bb 979   JJ bb 979   JJ bb 979}

do_execsql_test 1.3.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 158   BB bb 158   BB bb 158   BB bb 158   BB bb 158   BB bb 158   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 113   DD bb 113   DD bb 113   DD bb 113   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   II aa 102   II aa 102   II bb 102   II bb 102   II bb 102   II bb 102   II bb 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ bb 102   JJ bb 102   JJ bb 102   JJ bb 102}









do_execsql_test 1.4.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC bb 44737   CC bb 44737   DD aa 44737   DD aa 44737   DD aa 44737   DD bb 44737   DD bb 44737   DD bb 44737   DD bb 44737   EE aa 44737   EE aa 44737   EE bb 44737   EE bb 44737   EE bb 44737   FF aa 44737   FF aa 44737   FF aa 44737   FF aa 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   GG aa 44737   GG aa 44737   GG aa 44737   GG aa 44737   GG bb 44737   GG bb 44737   GG bb 44737   GG bb 44737   HH aa 44737   HH aa 44737   HH aa 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   II aa 44737   II aa 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}

do_execsql_test 1.4.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC bb 44737   CC bb 44737   DD aa 44737   DD aa 44737   DD aa 44737   DD bb 44737   DD bb 44737   DD bb 44737   DD bb 44737   EE aa 44737   EE aa 44737   EE bb 44737   EE bb 44737   EE bb 44737   FF aa 44737   FF aa 44737   FF aa 44737   FF aa 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   GG aa 44737   GG aa 44737   GG aa 44737   GG aa 44737   GG bb 44737   GG bb 44737   GG bb 44737   GG bb 44737   HH aa 44737   HH aa 44737   HH aa 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   II aa 44737   II aa 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ bb 979   JJ bb 979   JJ bb 979   JJ bb 979}

do_execsql_test 1.4.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   II aa 102   II aa 102   II bb 102   II bb 102   II bb 102   II bb 102   II bb 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ bb 102   JJ bb 102   JJ bb 102   JJ bb 102}









do_execsql_test 1.5.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.5.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.5.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}









do_execsql_test 1.6.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   CC aa 12025   CC aa 12025   CC aa 12025   CC aa 12025   CC bb 12025   CC bb 12025   DD aa 10462   DD aa 10462   DD aa 10462   DD bb 10462   DD bb 10462   DD bb 10462   DD bb 10462   EE aa 7154   EE aa 7154   EE bb 7154   EE bb 7154   EE bb 7154   FF aa 6571   FF aa 6571   FF aa 6571   FF aa 6571   FF bb 6571   FF bb 6571   FF bb 6571   FF bb 6571   FF bb 6571   FF bb 6571   GG aa 8207   GG aa 8207   GG aa 8207   GG aa 8207   GG bb 8207   GG bb 8207   GG bb 8207   GG bb 8207   HH aa 10136   HH aa 10136   HH aa 10136   HH bb 10136   HH bb 10136   HH bb 10136   HH bb 10136   HH bb 10136   HH bb 10136   II aa 9911   II aa 9911   II bb 9911   II bb 9911   II bb 9911   II bb 9911   II bb 9911   JJ aa 9083   JJ aa 9083   JJ aa 9083   JJ aa 9083   JJ bb 9083   JJ bb 9083   JJ bb 9083   JJ bb 9083}

do_execsql_test 1.6.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 2307   AA bb 2307   AA bb 2307   AA bb 2307   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 5251   BB bb 5251   BB bb 5251   BB bb 5251   BB bb 5251   BB bb 5251   CC aa 7340   CC aa 7340   CC aa 7340   CC aa 7340   CC bb 6421   CC bb 6421   DD aa 3122   DD aa 3122   DD aa 3122   DD bb 2493   DD bb 2493   DD bb 2493   DD bb 2493   EE aa 4032   EE aa 4032   EE bb 3597   EE bb 3597   EE bb 3597   FF aa 2539   FF aa 2539   FF aa 2539   FF aa 2539   FF bb 3812   FF bb 3812   FF bb 3812   FF bb 3812   FF bb 3812   FF bb 3812   GG aa 5668   GG aa 5668   GG aa 5668   GG aa 5668   GG bb 5102   GG bb 5102   GG bb 5102   GG bb 5102   HH aa 4468   HH aa 4468   HH aa 4468   HH bb 5120   HH bb 5120   HH bb 5120   HH bb 5120   HH bb 5120   HH bb 5120   II aa 5443   II aa 5443   II bb 4244   II bb 4244   II bb 4244   II bb 4244   II bb 4244   JJ aa 3640   JJ aa 3640   JJ aa 3640   JJ aa 3640   JJ bb 4604   JJ bb 4604   JJ bb 4604   JJ bb 4604}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 870   BB bb 870   BB bb 870   BB bb 870   BB bb 870   BB bb 870   CC aa 840   CC aa 840   CC aa 840   CC aa 840   CC bb 840   CC bb 840   DD aa 822   DD aa 822   DD aa 822   DD bb 845   DD bb 845   DD bb 845   DD bb 845   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 777   FF aa 777   FF aa 777   FF aa 777   FF bb 768   FF bb 768   FF bb 768   FF bb 768   FF bb 768   FF bb 768   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 938   HH aa 938   HH aa 938   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 963   II bb 963   II bb 963   II bb 963   II bb 963   JJ aa 805   JJ aa 805   JJ aa 805   JJ aa 805   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.6.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 247   BB bb 247   BB bb 247   BB bb 247   BB bb 247   BB bb 247   CC aa 247   CC aa 247   CC aa 247   CC aa 247   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 224   DD bb 224   DD bb 224   DD bb 224   EE aa 224   EE aa 224   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 208   FF bb 208   FF bb 208   FF bb 208   FF bb 208   FF bb 208   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 148   HH aa 148   HH aa 148   HH bb 160   HH bb 160   HH bb 160   HH bb 160   HH bb 160   HH bb 160   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 250   JJ aa 250   JJ aa 250   JJ aa 250   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}









do_execsql_test 1.7.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   CC aa 12025   CC aa 12025   CC aa 12025   CC aa 12025   CC bb 12025   CC bb 12025   DD aa 15147   DD aa 15147   DD aa 15147   DD bb 15147   DD bb 15147   DD bb 15147   DD bb 15147   EE aa 14494   EE aa 14494   EE bb 14494   EE bb 14494   EE bb 14494   FF aa 9693   FF aa 9693   FF aa 9693   FF aa 9693   FF bb 9693   FF bb 9693   FF bb 9693   FF bb 9693   FF bb 9693   FF bb 9693   GG aa 12239   GG aa 12239   GG aa 12239   GG aa 12239   GG bb 12239   GG bb 12239   GG bb 12239   GG bb 12239   HH aa 12675   HH aa 12675   HH aa 12675   HH bb 12675   HH bb 12675   HH bb 12675   HH bb 12675   HH bb 12675   HH bb 12675   II aa 15579   II aa 15579   II bb 15579   II bb 15579   II bb 15579   II bb 15579   II bb 15579   JJ aa 13551   JJ aa 13551   JJ aa 13551   JJ aa 13551   JJ bb 13551   JJ bb 13551   JJ bb 13551   JJ bb 13551}

do_execsql_test 1.7.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 2307   AA bb 2307   AA bb 2307   AA bb 2307   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   CC aa 9718   CC aa 9718   CC aa 9718   CC aa 9718   CC bb 9294   CC bb 9294   DD aa 7589   DD aa 7589   DD aa 7589   DD bb 4447   DD bb 4447   DD bb 4447   DD bb 4447   EE aa 5200   EE aa 5200   EE bb 4922   EE bb 4922   EE bb 4922   FF aa 5246   FF aa 5246   FF aa 5246   FF aa 5246   FF bb 4702   FF bb 4702   FF bb 4702   FF bb 4702   FF bb 4702   FF bb 4702   GG aa 7317   GG aa 7317   GG aa 7317   GG aa 7317   GG bb 7265   GG bb 7265   GG bb 7265   GG bb 7265   HH aa 7973   HH aa 7973   HH aa 7973   HH bb 6717   HH bb 6717   HH bb 6717   HH bb 6717   HH bb 6717   HH bb 6717   II aa 8314   II aa 8314   II bb 6493   II bb 6493   II bb 6493   II bb 6493   II bb 6493   JJ aa 6834   JJ aa 6834   JJ aa 6834   JJ aa 6834   JJ bb 5654   JJ bb 5654   JJ bb 5654   JJ bb 5654}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 870   CC aa 870   CC aa 870   CC aa 870   CC bb 840   CC bb 840   DD aa 840   DD aa 840   DD aa 840   DD bb 845   DD bb 845   DD bb 845   DD bb 845   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 777   FF bb 777   FF bb 777   FF bb 777   FF bb 777   FF bb 777   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 938   HH aa 938   HH aa 938   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 963   JJ aa 963   JJ aa 963   JJ aa 963   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.7.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 247   CC aa 247   CC aa 247   CC aa 247   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 224   EE aa 224   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 148   HH bb 148   HH bb 148   HH bb 148   HH bb 148   HH bb 148   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 133   JJ aa 133   JJ aa 133   JJ aa 133   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}









do_execsql_test 1.8.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 15147   CC bb 15147   DD aa 19179   DD aa 19179   DD aa 19179   DD bb 19179   DD bb 19179   DD bb 19179   DD bb 19179   EE aa 17033   EE aa 17033   EE bb 17033   EE bb 17033   EE bb 17033   FF aa 15361   FF aa 15361   FF aa 15361   FF aa 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   GG aa 16707   GG aa 16707   GG aa 16707   GG aa 16707   GG bb 16707   GG bb 16707   GG bb 16707   GG bb 16707   HH aa 18118   HH aa 18118   HH aa 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   II aa 19219   II aa 19219   II bb 19219   II bb 19219   II bb 19219   II bb 19219   II bb 19219   JJ aa 17351   JJ aa 17351   JJ aa 17351   JJ aa 17351   JJ bb 17351   JJ bb 17351   JJ bb 17351   JJ bb 17351}

do_execsql_test 1.8.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 11672   CC aa 11672   CC aa 11672   CC aa 11672   CC bb 10462   CC bb 10462   DD aa 8914   DD aa 8914   DD aa 8914   DD bb 7154   DD bb 7154   DD bb 7154   DD bb 7154   EE aa 6090   EE aa 6090   EE bb 6571   EE bb 6571   EE bb 6571   FF aa 7409   FF aa 7409   FF aa 7409   FF aa 7409   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   GG aa 8914   GG aa 8914   GG aa 8914   GG aa 8914   GG bb 10136   GG bb 10136   GG bb 10136   GG bb 10136   HH aa 10222   HH aa 10222   HH aa 10222   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   II aa 9364   II aa 9364   II bb 9083   II bb 9083   II bb 9083   II bb 9083   II bb 9083   JJ aa 8848   JJ aa 8848   JJ aa 8848   JJ aa 8848   JJ bb 7440   JJ bb 7440   JJ bb 7440   JJ bb 7440}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 870   CC aa 870   CC aa 870   CC aa 870   CC bb 840   CC bb 840   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 963   JJ aa 963   JJ aa 963   JJ aa 963   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.8.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}









do_execsql_test 1.9.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 15147   CC bb 15147   DD aa 14494   DD aa 14494   DD aa 14494   DD bb 14494   DD bb 14494   DD bb 14494   DD bb 14494   EE aa 9693   EE aa 9693   EE bb 9693   EE bb 9693   EE bb 9693   FF aa 12239   FF aa 12239   FF aa 12239   FF aa 12239   FF bb 12239   FF bb 12239   FF bb 12239   FF bb 12239   FF bb 12239   FF bb 12239   GG aa 12675   GG aa 12675   GG aa 12675   GG aa 12675   GG bb 12675   GG bb 12675   GG bb 12675   GG bb 12675   HH aa 15579   HH aa 15579   HH aa 15579   HH bb 15579   HH bb 15579   HH bb 15579   HH bb 15579   HH bb 15579   HH bb 15579   II aa 13551   II aa 13551   II bb 13551   II bb 13551   II bb 13551   II bb 13551   II bb 13551   JJ aa 12883   JJ aa 12883   JJ aa 12883   JJ aa 12883   JJ bb 12883   JJ bb 12883   JJ bb 12883   JJ bb 12883}

do_execsql_test 1.9.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB bb 9718   BB bb 9718   BB bb 9718   BB bb 9718   BB bb 9718   BB bb 9718   CC aa 9294   CC aa 9294   CC aa 9294   CC aa 9294   CC bb 7589   CC bb 7589   DD aa 4447   DD aa 4447   DD aa 4447   DD bb 5200   DD bb 5200   DD bb 5200   DD bb 5200   EE aa 4922   EE aa 4922   EE bb 5246   EE bb 5246   EE bb 5246   FF aa 4702   FF aa 4702   FF aa 4702   FF aa 4702   FF bb 7317   FF bb 7317   FF bb 7317   FF bb 7317   FF bb 7317   FF bb 7317   GG aa 7265   GG aa 7265   GG aa 7265   GG aa 7265   GG bb 7973   GG bb 7973   GG bb 7973   GG bb 7973   HH aa 6717   HH aa 6717   HH aa 6717   HH bb 8314   HH bb 8314   HH bb 8314   HH bb 8314   HH bb 8314   HH bb 8314   II aa 6493   II aa 6493   II bb 6834   II bb 6834   II bb 6834   II bb 6834   II bb 6834   JJ aa 5654   JJ aa 5654   JJ aa 5654   JJ aa 5654   JJ bb 6390   JJ bb 6390   JJ bb 6390   JJ bb 6390}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 870   BB bb 870   BB bb 870   BB bb 870   BB bb 870   BB bb 870   CC aa 840   CC aa 840   CC aa 840   CC aa 840   CC bb 840   CC bb 840   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 777   FF aa 777   FF aa 777   FF aa 777   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 963   II bb 963   II bb 963   II bb 963   II bb 963   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.9.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 247   BB bb 247   BB bb 247   BB bb 247   BB bb 247   BB bb 247   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 224   DD bb 224   DD bb 224   DD bb 224   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 148   HH aa 148   HH aa 148   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}









do_execsql_test 1.10.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 15147   CC bb 15147   DD aa 19179   DD aa 19179   DD aa 19179   DD bb 19179   DD bb 19179   DD bb 19179   DD bb 19179   EE aa 17033   EE aa 17033   EE bb 17033   EE bb 17033   EE bb 17033   FF aa 15361   FF aa 15361   FF aa 15361   FF aa 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   GG aa 16707   GG aa 16707   GG aa 16707   GG aa 16707   GG bb 16707   GG bb 16707   GG bb 16707   GG bb 16707   HH aa 18118   HH aa 18118   HH aa 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   II aa 19219   II aa 19219   II bb 19219   II bb 19219   II bb 19219   II bb 19219   II bb 19219   JJ aa 17351   JJ aa 17351   JJ aa 17351   JJ aa 17351   JJ bb 17351   JJ bb 17351   JJ bb 17351   JJ bb 17351}

do_execsql_test 1.10.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 11672   CC aa 11672   CC aa 11672   CC aa 11672   CC bb 10462   CC bb 10462   DD aa 8914   DD aa 8914   DD aa 8914   DD bb 7154   DD bb 7154   DD bb 7154   DD bb 7154   EE aa 6090   EE aa 6090   EE bb 6571   EE bb 6571   EE bb 6571   FF aa 7409   FF aa 7409   FF aa 7409   FF aa 7409   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   GG aa 8914   GG aa 8914   GG aa 8914   GG aa 8914   GG bb 10136   GG bb 10136   GG bb 10136   GG bb 10136   HH aa 10222   HH aa 10222   HH aa 10222   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   II aa 9364   II aa 9364   II bb 9083   II bb 9083   II bb 9083   II bb 9083   II bb 9083   JJ aa 8848   JJ aa 8848   JJ aa 8848   JJ aa 8848   JJ bb 7440   JJ bb 7440   JJ bb 7440   JJ bb 7440}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 870   CC aa 870   CC aa 870   CC aa 870   CC bb 840   CC bb 840   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 963   JJ aa 963   JJ aa 963   JJ aa 963   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.10.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}









do_execsql_test 1.11.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC bb 44737   CC bb 44737   DD aa 40052   DD aa 40052   DD aa 40052   DD bb 40052   DD bb 40052   DD bb 40052   DD bb 40052   EE aa 32712   EE aa 32712   EE bb 32712   EE bb 32712   EE bb 32712   FF aa 29590   FF aa 29590   FF aa 29590   FF aa 29590   FF bb 29590   FF bb 29590   FF bb 29590   FF bb 29590   FF bb 29590   FF bb 29590   GG aa 25558   GG aa 25558   GG aa 25558   GG aa 25558   GG bb 25558   GG bb 25558   GG bb 25558   GG bb 25558   HH aa 23019   HH aa 23019   HH aa 23019   HH bb 23019   HH bb 23019   HH bb 23019   HH bb 23019   HH bb 23019   HH bb 23019   II aa 17351   II aa 17351   II bb 17351   II bb 17351   II bb 17351   II bb 17351   II bb 17351   JJ aa 12883   JJ aa 12883   JJ aa 12883   JJ aa 12883   JJ bb 12883   JJ bb 12883   JJ bb 12883   JJ bb 12883}

do_execsql_test 1.11.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB bb 42430   BB bb 42430   BB bb 42430   BB bb 42430   BB bb 42430   BB bb 42430   CC aa 40052   CC aa 40052   CC aa 40052   CC aa 40052   CC bb 37179   CC bb 37179   DD aa 32712   DD aa 32712   DD aa 32712   DD bb 30758   DD bb 30758   DD bb 30758   DD bb 30758   EE aa 29590   EE aa 29590   EE bb 28265   EE bb 28265   EE bb 28265   FF aa 25558   FF aa 25558   FF aa 25558   FF aa 25558   FF bb 24668   FF bb 24668   FF bb 24668   FF bb 24668   FF bb 24668   FF bb 24668   GG aa 23019   GG aa 23019   GG aa 23019   GG aa 23019   GG bb 20856   GG bb 20856   GG bb 20856   GG bb 20856   HH aa 17351   HH aa 17351   HH aa 17351   HH bb 15754   HH bb 15754   HH bb 15754   HH bb 15754   HH bb 15754   HH bb 15754   II aa 12883   II aa 12883   II bb 10634   II bb 10634   II bb 10634   II bb 10634   II bb 10634   JJ aa 7440   JJ aa 7440   JJ aa 7440   JJ aa 7440   JJ bb 6390   JJ bb 6390   JJ bb 6390   JJ bb 6390}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 963   II bb 963   II bb 963   II bb 963   II bb 963   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.11.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}









do_execsql_test 1.12.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   CC aa 3122   CC aa 3122   CC aa 3122   CC aa 3122   CC bb 3122   CC bb 3122   DD aa 4032   DD aa 4032   DD aa 4032   DD bb 4032   DD bb 4032   DD bb 4032   DD bb 4032   EE aa 2539   EE aa 2539   EE bb 2539   EE bb 2539   EE bb 2539   FF aa 5668   FF aa 5668   FF aa 5668   FF aa 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   GG aa 4468   GG aa 4468   GG aa 4468   GG aa 4468   GG bb 4468   GG bb 4468   GG bb 4468   GG bb 4468   HH aa 5443   HH aa 5443   HH aa 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   II aa 3640   II aa 3640   II bb 3640   II bb 3640   II bb 3640   II bb 3640   II bb 3640   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.12.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 2378   AA bb 2378   AA bb 2378   AA bb 2378   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   CC aa 1954   CC aa 1954   CC aa 1954   CC aa 1954   CC bb 1168   CC bb 1168   DD aa 1325   DD aa 1325   DD aa 1325   DD bb 2707   DD bb 2707   DD bb 2707   DD bb 2707   EE aa 890   EE aa 890   EE bb 1649   EE bb 1649   EE bb 1649   FF aa 2163   FF aa 2163   FF aa 2163   FF aa 2163   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   GG aa 1597   GG aa 1597   GG aa 1597   GG aa 1597   GG bb 2871   GG bb 2871   GG bb 2871   GG bb 2871   HH aa 2249   HH aa 2249   HH aa 2249   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   II aa 1050   II aa 1050   II bb 2590   II bb 2590   II bb 2590   II bb 2590   II bb 2590   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 870   AA bb 870   AA bb 870   AA bb 870   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   CC aa 759   CC aa 759   CC aa 759   CC aa 759   CC bb 822   CC bb 822   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 777   EE aa 777   EE bb 768   EE bb 768   EE bb 768   FF aa 670   FF aa 670   FF aa 670   FF aa 670   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 634   GG aa 634   GG aa 634   GG aa 634   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 652   II aa 652   II bb 805   II bb 805   II bb 805   II bb 805   II bb 805   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.12.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 309   AA bb 309   AA bb 309   AA bb 309   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB bb 633   BB bb 633   BB bb 633   BB bb 633   BB bb 633   BB bb 633   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 346   CC bb 346   DD aa 224   DD aa 224   DD aa 224   DD bb 238   DD bb 238   DD bb 238   DD bb 238   EE aa 113   EE aa 113   EE bb 252   EE bb 252   EE bb 252   FF aa 208   FF aa 208   FF aa 208   FF aa 208   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 148   GG aa 148   GG aa 148   GG aa 148   GG bb 160   GG bb 160   GG bb 160   GG bb 160   HH aa 480   HH aa 480   HH aa 480   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 398   II aa 398   II bb 250   II bb 250   II bb 250   II bb 250   II bb 250   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}









do_execsql_test 1.13.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 12025   AA aa 12025   AA aa 12025   AA aa 12025   AA bb 12025   AA bb 12025   AA bb 12025   AA bb 12025   BB aa 10462   BB aa 10462   BB aa 10462   BB aa 10462   BB aa 10462   BB aa 10462   BB bb 10462   BB bb 10462   BB bb 10462   BB bb 10462   BB bb 10462   BB bb 10462   CC aa 7154   CC aa 7154   CC aa 7154   CC aa 7154   CC bb 7154   CC bb 7154   DD aa 6571   DD aa 6571   DD aa 6571   DD bb 6571   DD bb 6571   DD bb 6571   DD bb 6571   EE aa 8207   EE aa 8207   EE bb 8207   EE bb 8207   EE bb 8207   FF aa 10136   FF aa 10136   FF aa 10136   FF aa 10136   FF bb 10136   FF bb 10136   FF bb 10136   FF bb 10136   FF bb 10136   FF bb 10136   GG aa 9911   GG aa 9911   GG aa 9911   GG aa 9911   GG bb 9911   GG bb 9911   GG bb 9911   GG bb 9911   HH aa 9083   HH aa 9083   HH aa 9083   HH bb 9083   HH bb 9083   HH bb 9083   HH bb 9083   HH bb 9083   HH bb 9083   II aa 7440   II aa 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.13.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 5251   AA bb 5251   AA bb 5251   AA bb 5251   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB bb 6421   BB bb 6421   BB bb 6421   BB bb 6421   BB bb 6421   BB bb 6421   CC aa 3122   CC aa 3122   CC aa 3122   CC aa 3122   CC bb 2493   CC bb 2493   DD aa 4032   DD aa 4032   DD aa 4032   DD bb 3597   DD bb 3597   DD bb 3597   DD bb 3597   EE aa 2539   EE aa 2539   EE bb 3812   EE bb 3812   EE bb 3812   FF aa 5668   FF aa 5668   FF aa 5668   FF aa 5668   FF bb 5102   FF bb 5102   FF bb 5102   FF bb 5102   FF bb 5102   FF bb 5102   GG aa 4468   GG aa 4468   GG aa 4468   GG aa 4468   GG bb 5120   GG bb 5120   GG bb 5120   GG bb 5120   HH aa 5443   HH aa 5443   HH aa 5443   HH bb 4244   HH bb 4244   HH bb 4244   HH bb 4244   HH bb 4244   HH bb 4244   II aa 3640   II aa 3640   II bb 4604   II bb 4604   II bb 4604   II bb 4604   II bb 4604   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 870   AA bb 870   AA bb 870   AA bb 870   BB aa 840   BB aa 840   BB aa 840   BB aa 840   BB aa 840   BB aa 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   CC aa 822   CC aa 822   CC aa 822   CC aa 822   CC bb 845   CC bb 845   DD aa 959   DD aa 959   DD aa 959   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 777   EE aa 777   EE bb 768   EE bb 768   EE bb 768   FF aa 938   FF aa 938   FF aa 938   FF aa 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 805   II aa 805   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.13.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 247   AA bb 247   AA bb 247   AA bb 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB bb 158   BB bb 158   BB bb 158   BB bb 158   BB bb 158   BB bb 158   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 224   CC bb 224   DD aa 224   DD aa 224   DD aa 224   DD bb 113   DD bb 113   DD bb 113   DD bb 113   EE aa 113   EE aa 113   EE bb 208   EE bb 208   EE bb 208   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 148   GG aa 148   GG aa 148   GG aa 148   GG bb 160   GG bb 160   GG bb 160   GG bb 160   HH aa 133   HH aa 133   HH aa 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 250   II aa 250   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}









do_execsql_test 1.14.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   CC aa 32712   CC aa 32712   CC aa 32712   CC aa 32712   CC bb 32712   CC bb 32712   DD aa 29590   DD aa 29590   DD aa 29590   DD bb 29590   DD bb 29590   DD bb 29590   DD bb 29590   EE aa 25558   EE aa 25558   EE bb 25558   EE bb 25558   EE bb 25558   FF aa 23019   FF aa 23019   FF aa 23019   FF aa 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   GG aa 17351   GG aa 17351   GG aa 17351   GG aa 17351   GG bb 17351   GG bb 17351   GG bb 17351   GG bb 17351   HH aa 12883   HH aa 12883   HH aa 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   II aa 7440   II aa 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.14.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 42430   AA bb 42430   AA bb 42430   AA bb 42430   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   CC aa 32712   CC aa 32712   CC aa 32712   CC aa 32712   CC bb 30758   CC bb 30758   DD aa 29590   DD aa 29590   DD aa 29590   DD bb 28265   DD bb 28265   DD bb 28265   DD bb 28265   EE aa 25558   EE aa 25558   EE bb 24668   EE bb 24668   EE bb 24668   FF aa 23019   FF aa 23019   FF aa 23019   FF aa 23019   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   GG aa 17351   GG aa 17351   GG aa 17351   GG aa 17351   GG bb 15754   GG bb 15754   GG bb 15754   GG bb 15754   HH aa 12883   HH aa 12883   HH aa 12883   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   II aa 7440   II aa 7440   II bb 6390   II bb 6390   II bb 6390   II bb 6390   II bb 6390   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 899   II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.14.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 113   GG aa 113   GG aa 113   GG aa 113   GG bb 113   GG bb 113   GG bb 113   GG bb 113   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}









do_execsql_test 1.15.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   CC aa 32712   CC aa 32712   CC aa 32712   CC aa 32712   CC bb 32712   CC bb 32712   DD aa 29590   DD aa 29590   DD aa 29590   DD bb 29590   DD bb 29590   DD bb 29590   DD bb 29590   EE aa 25558   EE aa 25558   EE bb 25558   EE bb 25558   EE bb 25558   FF aa 23019   FF aa 23019   FF aa 23019   FF aa 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   GG aa 17351   GG aa 17351   GG aa 17351   GG aa 17351   GG bb 17351   GG bb 17351   GG bb 17351   GG bb 17351   HH aa 12883   HH aa 12883   HH aa 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   II aa 7440   II aa 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.15.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 42430   AA bb 42430   AA bb 42430   AA bb 42430   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   CC aa 32712   CC aa 32712   CC aa 32712   CC aa 32712   CC bb 30758   CC bb 30758   DD aa 29590   DD aa 29590   DD aa 29590   DD bb 28265   DD bb 28265   DD bb 28265   DD bb 28265   EE aa 25558   EE aa 25558   EE bb 24668   EE bb 24668   EE bb 24668   FF aa 23019   FF aa 23019   FF aa 23019   FF aa 23019   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   GG aa 17351   GG aa 17351   GG aa 17351   GG aa 17351   GG bb 15754   GG bb 15754   GG bb 15754   GG bb 15754   HH aa 12883   HH aa 12883   HH aa 12883   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   II aa 7440   II aa 7440   II bb 6390   II bb 6390   II bb 6390   II bb 6390   II bb 6390   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 899   II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.15.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 113   GG aa 113   GG aa 113   GG aa 113   GG bb 113   GG bb 113   GG bb 113   GG bb 113   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}









do_execsql_test 1.16.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   CC aa 3122   CC aa 3122   CC aa 3122   CC aa 3122   CC bb 3122   CC bb 3122   DD aa 4032   DD aa 4032   DD aa 4032   DD bb 4032   DD bb 4032   DD bb 4032   DD bb 4032   EE aa 2539   EE aa 2539   EE bb 2539   EE bb 2539   EE bb 2539   FF aa 5668   FF aa 5668   FF aa 5668   FF aa 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   GG aa 4468   GG aa 4468   GG aa 4468   GG aa 4468   GG bb 4468   GG bb 4468   GG bb 4468   GG bb 4468   HH aa 5443   HH aa 5443   HH aa 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   II aa 3640   II aa 3640   II bb 3640   II bb 3640   II bb 3640   II bb 3640   II bb 3640   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.16.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 2378   AA bb 2378   AA bb 2378   AA bb 2378   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   CC aa 1954   CC aa 1954   CC aa 1954   CC aa 1954   CC bb 1168   CC bb 1168   DD aa 1325   DD aa 1325   DD aa 1325   DD bb 2707   DD bb 2707   DD bb 2707   DD bb 2707   EE aa 890   EE aa 890   EE bb 1649   EE bb 1649   EE bb 1649   FF aa 2163   FF aa 2163   FF aa 2163   FF aa 2163   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   GG aa 1597   GG aa 1597   GG aa 1597   GG aa 1597   GG bb 2871   GG bb 2871   GG bb 2871   GG bb 2871   HH aa 2249   HH aa 2249   HH aa 2249   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   II aa 1050   II aa 1050   II bb 2590   II bb 2590   II bb 2590   II bb 2590   II bb 2590   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 870   AA bb 870   AA bb 870   AA bb 870   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   CC aa 759   CC aa 759   CC aa 759   CC aa 759   CC bb 822   CC bb 822   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 777   EE aa 777   EE bb 768   EE bb 768   EE bb 768   FF aa 670   FF aa 670   FF aa 670   FF aa 670   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 634   GG aa 634   GG aa 634   GG aa 634   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 652   II aa 652   II bb 805   II bb 805   II bb 805   II bb 805   II bb 805   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.16.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 309   AA bb 309   AA bb 309   AA bb 309   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB bb 633   BB bb 633   BB bb 633   BB bb 633   BB bb 633   BB bb 633   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 346   CC bb 346   DD aa 224   DD aa 224   DD aa 224   DD bb 238   DD bb 238   DD bb 238   DD bb 238   EE aa 113   EE aa 113   EE bb 252   EE bb 252   EE bb 252   FF aa 208   FF aa 208   FF aa 208   FF aa 208   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 148   GG aa 148   GG aa 148   GG aa 148   GG bb 160   GG bb 160   GG bb 160   GG bb 160   HH aa 480   HH aa 480   HH aa 480   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 398   II aa 398   II bb 250   II bb 250   II bb 250   II bb 250   II bb 250   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}









do_execsql_test 1.17.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.17.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.17.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}









do_execsql_test 1.18.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 22701   AA aa 22701   AA aa 22701   AA aa 22701   AA bb 22701   AA bb 22701   AA bb 22701   AA bb 22701   BB aa 19829   BB aa 19829   BB aa 19829   BB aa 19829   BB aa 19829   BB aa 19829   BB bb 19829   BB bb 19829   BB bb 19829   BB bb 19829   BB bb 19829   BB bb 19829   CC aa 22150   CC aa 22150   CC aa 22150   CC aa 22150   CC bb 22150   CC bb 22150   DD aa 21758   DD aa 21758   DD aa 21758   DD bb 21758   DD bb 21758   DD bb 21758   DD bb 21758   EE aa 23019   EE aa 23019   EE bb 23019   EE bb 23019   EE bb 23019   FF aa 17351   FF aa 17351   FF aa 17351   FF aa 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   GG aa 12883   GG aa 12883   GG aa 12883   GG aa 12883   GG bb 12883   GG bb 12883   GG bb 12883   GG bb 12883   HH aa 7440   HH aa 7440   HH aa 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 3800   II aa 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.18.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 12840   AA aa 12840   AA aa 12840   AA aa 12840   AA bb 11787   AA bb 11787   AA bb 11787   AA bb 11787   BB aa 11621   BB aa 11621   BB aa 11621   BB aa 11621   BB aa 11621   BB aa 11621   BB bb 8044   BB bb 8044   BB bb 8044   BB bb 8044   BB bb 8044   BB bb 8044   CC aa 7739   CC aa 7739   CC aa 7739   CC aa 7739   CC bb 8734   CC bb 8734   DD aa 10914   DD aa 10914   DD aa 10914   DD bb 9804   DD bb 9804   DD bb 9804   DD bb 9804   EE aa 11785   EE aa 11785   EE bb 12385   EE bb 12385   EE bb 12385   FF aa 13416   FF aa 13416   FF aa 13416   FF aa 13416   FF bb 10961   FF bb 10961   FF bb 10961   FF bb 10961   FF bb 10961   FF bb 10961   GG aa 11954   GG aa 11954   GG aa 11954   GG aa 11954   GG bb 11097   GG bb 11097   GG bb 11097   GG bb 11097   HH aa 10634   HH aa 10634   HH aa 10634   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 6390   II aa 6390   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 870   AA aa 870   AA aa 870   AA aa 870   AA bb 845   AA bb 845   AA bb 845   AA bb 845   BB aa 959   BB aa 959   BB aa 959   BB aa 959   BB aa 959   BB aa 959   BB bb 959   BB bb 959   BB bb 959   BB bb 959   BB bb 959   BB bb 959   CC aa 959   CC aa 959   CC aa 959   CC aa 959   CC bb 959   CC bb 959   DD aa 959   DD aa 959   DD aa 959   DD bb 938   DD bb 938   DD bb 938   DD bb 938   EE aa 938   EE aa 938   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 963   HH aa 963   HH aa 963   HH bb 899   HH bb 899   HH bb 899   HH bb 899   HH bb 899   HH bb 899   II aa 899   II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 839   JJ aa 839   JJ aa 839   JJ aa 839   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.18.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 158   AA aa 158   AA aa 158   AA aa 158   AA bb 158   AA bb 158   AA bb 158   AA bb 158   BB aa 158   BB aa 158   BB aa 158   BB aa 158   BB aa 158   BB aa 158   BB bb 113   BB bb 113   BB bb 113   BB bb 113   BB bb 113   BB bb 113   CC aa 113   CC aa 113   CC aa 113   CC aa 113   CC bb 113   CC bb 113   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 133   FF bb 133   FF bb 133   FF bb 133   FF bb 133   FF bb 133   GG aa 133   GG aa 133   GG aa 133   GG aa 133   GG bb 113   GG bb 113   GG bb 113   GG bb 113   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 257   JJ aa 257   JJ aa 257   JJ aa 257   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}









do_execsql_test 1.19.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 40052   AA aa 40052   AA aa 40052   AA aa 40052   AA bb 40052   AA bb 40052   AA bb 40052   AA bb 40052   BB aa 32712   BB aa 32712   BB aa 32712   BB aa 32712   BB aa 32712   BB aa 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   CC aa 29590   CC aa 29590   CC aa 29590   CC aa 29590   CC bb 29590   CC bb 29590   DD aa 25558   DD aa 25558   DD aa 25558   DD bb 25558   DD bb 25558   DD bb 25558   DD bb 25558   EE aa 23019   EE aa 23019   EE bb 23019   EE bb 23019   EE bb 23019   FF aa 17351   FF aa 17351   FF aa 17351   FF aa 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   GG aa 12883   GG aa 12883   GG aa 12883   GG aa 12883   GG bb 12883   GG bb 12883   GG bb 12883   GG bb 12883   HH aa 7440   HH aa 7440   HH aa 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 3800   II aa 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.19.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 42430   AA aa 42430   AA aa 42430   AA aa 42430   AA bb 40052   AA bb 40052   AA bb 40052   AA bb 40052   BB aa 37179   BB aa 37179   BB aa 37179   BB aa 37179   BB aa 37179   BB aa 37179   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   CC aa 30758   CC aa 30758   CC aa 30758   CC aa 30758   CC bb 29590   CC bb 29590   DD aa 28265   DD aa 28265   DD aa 28265   DD bb 25558   DD bb 25558   DD bb 25558   DD bb 25558   EE aa 24668   EE aa 24668   EE bb 23019   EE bb 23019   EE bb 23019   FF aa 20856   FF aa 20856   FF aa 20856   FF aa 20856   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   GG aa 15754   GG aa 15754   GG aa 15754   GG aa 15754   GG bb 12883   GG bb 12883   GG bb 12883   GG bb 12883   HH aa 10634   HH aa 10634   HH aa 10634   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 6390   II aa 6390   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 963   HH aa 963   HH aa 963   HH bb 899   HH bb 899   HH bb 899   HH bb 899   HH bb 899   HH bb 899   II aa 899   II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 839   JJ aa 839   JJ aa 839   JJ aa 839   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.19.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   GG aa 113   GG aa 113   GG aa 113   GG aa 113   GG bb 113   GG bb 113   GG bb 113   GG bb 113   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 257   JJ aa 257   JJ aa 257   JJ aa 257   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}









do_execsql_test 2.1.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE NO OTHERS 
    )
} {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   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80}

do_execsql_test 2.1.2 {
  SELECT nth_value(c, 14) OVER win 
    FROM t3


    WINDOW win AS (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE NO OTHERS )
} {938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938}



do_execsql_test 2.2.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW 
    )
} {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   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80}

do_execsql_test 2.2.2 {
  SELECT nth_value(c, 14) OVER win 
    FROM t3


    WINDOW win AS (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW )
} {660   660   660   660   660   660   660   660   660   660   660   660   660   660   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938   938}



do_execsql_test 2.3.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE GROUP 
    )
} {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   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80}

do_execsql_test 2.3.2 {
  SELECT nth_value(c, 14) OVER win 
    FROM t3


    WINDOW win AS (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE GROUP )
} {{}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}}



do_execsql_test 2.4.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE TIES 
    )
} {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   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80}

do_execsql_test 2.4.2 {
  SELECT nth_value(c, 14) OVER win 
    FROM t3


    WINDOW win AS (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE TIES )
} {{}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}   {}}



#==========================================================================

do_execsql_test 3.0 {
  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(a REAL, b INTEGER);
  INSERT INTO t1 VALUES







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>












>
>
|
<
>
>













>
>
|
<
>
>













>
>
|
<
>
>













>
>
|
<
>
>







69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
..
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
...
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
...
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
...
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
...
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
...
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
...
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
...
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
...
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
...
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
...
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
...
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602

603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620

621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638

639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656

657
658
659
660
661
662
663
664
665
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 934   CC aa 934   CC aa 934   CC aa 934   CC bb 934   CC bb 934   DD aa 934   DD aa 934   DD aa 934   DD bb 934   DD bb 934   DD bb 934   DD bb 934   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   GG aa 959   GG aa 959   GG aa 959   GG aa 959   GG bb 959   GG bb 959   GG bb 959   GG bb 959   HH aa 959   HH aa 959   HH aa 959   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ bb 979   JJ bb 979   JJ bb 979   JJ bb 979}

do_execsql_test 1.1.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 223   CC aa 223   CC aa 223   CC aa 223   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 158   EE aa 158   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   II aa 102   II aa 102   II bb 102   II bb 102   II bb 102   II bb 102   II bb 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ bb 102   JJ bb 102   JJ bb 102   JJ bb 102}

do_execsql_test 1.1.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   CC aa 12025   CC aa 12025   CC aa 12025   CC aa 12025   CC bb 12025   CC bb 12025   DD aa 15147   DD aa 15147   DD aa 15147   DD bb 15147   DD bb 15147   DD bb 15147   DD bb 15147   EE aa 19179   EE aa 19179   EE bb 19179   EE bb 19179   EE bb 19179   FF aa 21718   FF aa 21718   FF aa 21718   FF aa 21718   FF bb 21718   FF bb 21718   FF bb 21718   FF bb 21718   FF bb 21718   FF bb 21718   GG aa 27386   GG aa 27386   GG aa 27386   GG aa 27386   GG bb 27386   GG bb 27386   GG bb 27386   GG bb 27386   HH aa 31854   HH aa 31854   HH aa 31854   HH bb 31854   HH bb 31854   HH bb 31854   HH bb 31854   HH bb 31854   HH bb 31854   II aa 37297   II aa 37297   II bb 37297   II bb 37297   II bb 37297   II bb 37297   II bb 37297   JJ aa 40937   JJ aa 40937   JJ aa 40937   JJ aa 40937   JJ bb 40937   JJ bb 40937   JJ bb 40937   JJ bb 40937}

do_execsql_test 1.1.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 2307   AA bb 2307   AA bb 2307   AA bb 2307   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   CC aa 12025   CC aa 12025   CC aa 12025   CC aa 12025   CC bb 13979   CC bb 13979   DD aa 15147   DD aa 15147   DD aa 15147   DD bb 16472   DD bb 16472   DD bb 16472   DD bb 16472   EE aa 19179   EE aa 19179   EE bb 20069   EE bb 20069   EE bb 20069   FF aa 21718   FF aa 21718   FF aa 21718   FF aa 21718   FF bb 23881   FF bb 23881   FF bb 23881   FF bb 23881   FF bb 23881   FF bb 23881   GG aa 27386   GG aa 27386   GG aa 27386   GG aa 27386   GG bb 28983   GG bb 28983   GG bb 28983   GG bb 28983   HH aa 31854   HH aa 31854   HH aa 31854   HH bb 34103   HH bb 34103   HH bb 34103   HH bb 34103   HH bb 34103   HH bb 34103   II aa 37297   II aa 37297   II bb 38347   II bb 38347   II bb 38347   II bb 38347   II bb 38347   JJ aa 40937   JJ aa 40937   JJ aa 40937   JJ aa 40937   JJ bb 42951   JJ bb 42951   JJ bb 42951   JJ bb 42951}

do_execsql_test 1.2.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 15147   CC bb 15147   DD aa 19179   DD aa 19179   DD aa 19179   DD bb 19179   DD bb 19179   DD bb 19179   DD bb 19179   EE aa 21718   EE aa 21718   EE bb 21718   EE bb 21718   EE bb 21718   FF aa 27386   FF aa 27386   FF aa 27386   FF aa 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   GG aa 31854   GG aa 31854   GG aa 31854   GG aa 31854   GG bb 31854   GG bb 31854   GG bb 31854   GG bb 31854   HH aa 37297   HH aa 37297   HH aa 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   II aa 40937   II aa 40937   II bb 40937   II bb 40937   II bb 40937   II bb 40937   II bb 40937   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}

do_execsql_test 1.2.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 13979   CC aa 13979   CC aa 13979   CC aa 13979   CC bb 15147   CC bb 15147   DD aa 16472   DD aa 16472   DD aa 16472   DD bb 19179   DD bb 19179   DD bb 19179   DD bb 19179   EE aa 20069   EE aa 20069   EE bb 21718   EE bb 21718   EE bb 21718   FF aa 23881   FF aa 23881   FF aa 23881   FF aa 23881   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   FF bb 27386   GG aa 28983   GG aa 28983   GG aa 28983   GG aa 28983   GG bb 31854   GG bb 31854   GG bb 31854   GG bb 31854   HH aa 34103   HH aa 34103   HH aa 34103   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   HH bb 37297   II aa 38347   II aa 38347   II bb 40937   II bb 40937   II bb 40937   II bb 40937   II bb 40937   JJ aa 42951   JJ aa 42951   JJ aa 42951   JJ aa 42951   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 934   CC aa 934   CC aa 934   CC aa 934   CC bb 934   CC bb 934   DD aa 934   DD aa 934   DD aa 934   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   GG aa 959   GG aa 959   GG aa 959   GG aa 959   GG bb 959   GG bb 959   GG bb 959   GG bb 959   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ bb 979   JJ bb 979   JJ bb 979   JJ bb 979}

do_execsql_test 1.2.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   II aa 102   II aa 102   II bb 102   II bb 102   II bb 102   II bb 102   II bb 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ bb 102   JJ bb 102   JJ bb 102   JJ bb 102}

do_execsql_test 1.2.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751   AA aa 3774   AA aa 4446   AA aa 4462   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 11263   BB aa 11365   BB aa 11613   BB aa 11626   BB aa 11632   BB aa 11778   BB bb 11185   BB bb 11233   BB bb 11239   BB bb 11314   BB bb 11320   BB bb 11392   CC aa 14388   CC aa 14540   CC aa 14717   CC aa 14989   CC bb 14325   CC bb 14801   DD aa 18334   DD aa 18923   DD aa 18955   DD bb 18220   DD bb 18385   DD bb 18463   DD bb 18941   EE aa 20941   EE aa 21605   EE bb 20950   EE bb 21089   EE bb 21466   FF aa 26716   FF aa 26719   FF aa 26768   FF aa 27178   FF bb 26448   FF bb 26516   FF bb 26660   FF bb 26812   FF bb 27091   FF bb 27284   GG aa 31220   GG aa 31374   GG aa 31519   GG aa 31706   GG bb 30916   GG bb 30925   GG bb 31010   GG bb 31694   HH aa 36318   HH aa 36507   HH aa 36817   HH bb 36334   HH bb 36567   HH bb 36614   HH bb 36942   HH bb 36967   HH bb 37164   II aa 40285   II aa 40539   II bb 40132   II bb 40266   II bb 40494   II bb 40516   II bb 40687   JJ aa 43838   JJ aa 43969   JJ aa 44503   JJ aa 44624   JJ bb 43898   JJ bb 44383   JJ bb 44401   JJ bb 44480}

do_execsql_test 1.2.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1373   AA aa 1396   AA aa 2068   AA aa 2084   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 6796   BB aa 6898   BB aa 7146   BB aa 7159   BB aa 7165   BB aa 7311   BB bb 11185   BB bb 11233   BB bb 11239   BB bb 11314   BB bb 11320   BB bb 11392   CC aa 13220   CC aa 13372   CC aa 13549   CC aa 13821   CC bb 14325   CC bb 14801   DD aa 15627   DD aa 16216   DD aa 16248   DD bb 18220   DD bb 18385   DD bb 18463   DD bb 18941   EE aa 19292   EE aa 19956   EE bb 20950   EE bb 21089   EE bb 21466   FF aa 23211   FF aa 23214   FF aa 23263   FF aa 23673   FF bb 26448   FF bb 26516   FF bb 26660   FF bb 26812   FF bb 27091   FF bb 27284   GG aa 28349   GG aa 28503   GG aa 28648   GG aa 28835   GG bb 30916   GG bb 30925   GG bb 31010   GG bb 31694   HH aa 33124   HH aa 33313   HH aa 33623   HH bb 36334   HH bb 36567   HH bb 36614   HH bb 36942   HH bb 36967   HH bb 37164   II aa 37695   II aa 37949   II bb 40132   II bb 40266   II bb 40494   II bb 40516   II bb 40687   JJ aa 42052   JJ aa 42183   JJ aa 42717   JJ aa 42838   JJ bb 43898   JJ bb 44383   JJ bb 44401   JJ bb 44480}

do_execsql_test 1.3.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 12025   AA aa 12025   AA aa 12025   AA aa 12025   AA bb 12025   AA bb 12025   AA bb 12025   AA bb 12025   BB aa 15147   BB aa 15147   BB aa 15147   BB aa 15147   BB aa 15147   BB aa 15147   BB bb 15147   BB bb 15147   BB bb 15147   BB bb 15147   BB bb 15147   BB bb 15147   CC aa 19179   CC aa 19179   CC aa 19179   CC aa 19179   CC bb 19179   CC bb 19179   DD aa 21718   DD aa 21718   DD aa 21718   DD bb 21718   DD bb 21718   DD bb 21718   DD bb 21718   EE aa 27386   EE aa 27386   EE bb 27386   EE bb 27386   EE bb 27386   FF aa 31854   FF aa 31854   FF aa 31854   FF aa 31854   FF bb 31854   FF bb 31854   FF bb 31854   FF bb 31854   FF bb 31854   FF bb 31854   GG aa 37297   GG aa 37297   GG aa 37297   GG aa 37297   GG bb 37297   GG bb 37297   GG bb 37297   GG bb 37297   HH aa 40937   HH aa 40937   HH aa 40937   HH bb 40937   HH bb 40937   HH bb 40937   HH bb 40937   HH bb 40937   HH bb 40937   II aa 44737   II aa 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}

do_execsql_test 1.3.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 7558   AA bb 7558   AA bb 7558   AA bb 7558   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 13979   BB bb 13979   BB bb 13979   BB bb 13979   BB bb 13979   BB bb 13979   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 16472   CC bb 16472   DD aa 19179   DD aa 19179   DD aa 19179   DD bb 20069   DD bb 20069   DD bb 20069   DD bb 20069   EE aa 21718   EE aa 21718   EE bb 23881   EE bb 23881   EE bb 23881   FF aa 27386   FF aa 27386   FF aa 27386   FF aa 27386   FF bb 28983   FF bb 28983   FF bb 28983   FF bb 28983   FF bb 28983   FF bb 28983   GG aa 31854   GG aa 31854   GG aa 31854   GG aa 31854   GG bb 34103   GG bb 34103   GG bb 34103   GG bb 34103   HH aa 37297   HH aa 37297   HH aa 37297   HH bb 38347   HH bb 38347   HH bb 38347   HH bb 38347   HH bb 38347   HH bb 38347   II aa 40937   II aa 40937   II bb 42951   II bb 42951   II bb 42951   II bb 42951   II bb 42951   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 934   CC aa 934   CC aa 934   CC aa 934   CC bb 934   CC bb 934   DD aa 959   DD aa 959   DD aa 959   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   FF bb 959   GG aa 959   GG aa 959   GG aa 959   GG aa 959   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ bb 979   JJ bb 979   JJ bb 979   JJ bb 979}

do_execsql_test 1.3.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 158   BB bb 158   BB bb 158   BB bb 158   BB bb 158   BB bb 158   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 113   DD bb 113   DD bb 113   DD bb 113   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   II aa 102   II aa 102   II bb 102   II bb 102   II bb 102   II bb 102   II bb 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ bb 102   JJ bb 102   JJ bb 102   JJ bb 102}

do_execsql_test 1.3.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 11091   AA aa 11114   AA aa 11786   AA aa 11802   AA bb 11155   AA bb 11398   AA bb 11453   AA bb 11716   BB aa 14385   BB aa 14487   BB aa 14735   BB aa 14748   BB aa 14754   BB aa 14900   BB bb 14307   BB bb 14355   BB bb 14361   BB bb 14436   BB bb 14442   BB bb 14514   CC aa 18420   CC aa 18572   CC aa 18749   CC aa 19021   CC bb 18357   CC bb 18833   DD aa 20873   DD aa 21462   DD aa 21494   DD bb 20759   DD bb 20924   DD bb 21002   DD bb 21480   EE aa 26609   EE aa 27273   EE bb 26618   EE bb 26757   EE bb 27134   FF aa 31184   FF aa 31187   FF aa 31236   FF aa 31646   FF bb 30916   FF bb 30984   FF bb 31128   FF bb 31280   FF bb 31559   FF bb 31752   GG aa 36663   GG aa 36817   GG aa 36962   GG aa 37149   GG bb 36359   GG bb 36368   GG bb 36453   GG bb 37137   HH aa 39958   HH aa 40147   HH aa 40457   HH bb 39974   HH bb 40207   HH bb 40254   HH bb 40582   HH bb 40607   HH bb 40804   II aa 44085   II aa 44339   II bb 43932   II bb 44066   II bb 44294   II bb 44316   II bb 44487   JJ aa 43838   JJ aa 43969   JJ aa 44503   JJ aa 44624   JJ bb 43898   JJ bb 44383   JJ bb 44401   JJ bb 44480}

do_execsql_test 1.3.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751   AA aa 3774   AA aa 4446   AA aa 4462   AA bb 6688   AA bb 6931   AA bb 6986   AA bb 7249   BB aa 11263   BB aa 11365   BB aa 11613   BB aa 11626   BB aa 11632   BB aa 11778   BB bb 13139   BB bb 13187   BB bb 13193   BB bb 13268   BB bb 13274   BB bb 13346   CC aa 14388   CC aa 14540   CC aa 14717   CC aa 14989   CC bb 15650   CC bb 16126   DD aa 18334   DD aa 18923   DD aa 18955   DD bb 19110   DD bb 19275   DD bb 19353   DD bb 19831   EE aa 20941   EE aa 21605   EE bb 23113   EE bb 23252   EE bb 23629   FF aa 26716   FF aa 26719   FF aa 26768   FF aa 27178   FF bb 28045   FF bb 28113   FF bb 28257   FF bb 28409   FF bb 28688   FF bb 28881   GG aa 31220   GG aa 31374   GG aa 31519   GG aa 31706   GG bb 33165   GG bb 33174   GG bb 33259   GG bb 33943   HH aa 36318   HH aa 36507   HH aa 36817   HH bb 37384   HH bb 37617   HH bb 37664   HH bb 37992   HH bb 38017   HH bb 38214   II aa 40285   II aa 40539   II bb 42146   II bb 42280   II bb 42508   II bb 42530   II bb 42701   JJ aa 43838   JJ aa 43969   JJ aa 44503   JJ aa 44624   JJ bb 43898   JJ bb 44383   JJ bb 44401   JJ bb 44480}

do_execsql_test 1.4.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC bb 44737   CC bb 44737   DD aa 44737   DD aa 44737   DD aa 44737   DD bb 44737   DD bb 44737   DD bb 44737   DD bb 44737   EE aa 44737   EE aa 44737   EE bb 44737   EE bb 44737   EE bb 44737   FF aa 44737   FF aa 44737   FF aa 44737   FF aa 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   GG aa 44737   GG aa 44737   GG aa 44737   GG aa 44737   GG bb 44737   GG bb 44737   GG bb 44737   GG bb 44737   HH aa 44737   HH aa 44737   HH aa 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   II aa 44737   II aa 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}

do_execsql_test 1.4.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC bb 44737   CC bb 44737   DD aa 44737   DD aa 44737   DD aa 44737   DD bb 44737   DD bb 44737   DD bb 44737   DD bb 44737   EE aa 44737   EE aa 44737   EE bb 44737   EE bb 44737   EE bb 44737   FF aa 44737   FF aa 44737   FF aa 44737   FF aa 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   FF bb 44737   GG aa 44737   GG aa 44737   GG aa 44737   GG aa 44737   GG bb 44737   GG bb 44737   GG bb 44737   GG bb 44737   HH aa 44737   HH aa 44737   HH aa 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   HH bb 44737   II aa 44737   II aa 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   II bb 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ aa 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737   JJ bb 44737}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ aa 979   JJ bb 979   JJ bb 979   JJ bb 979   JJ bb 979}

do_execsql_test 1.4.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   HH bb 102   II aa 102   II aa 102   II bb 102   II bb 102   II bb 102   II bb 102   II bb 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ aa 102   JJ bb 102   JJ bb 102   JJ bb 102   JJ bb 102}

do_execsql_test 1.4.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803   AA aa 43826   AA aa 44498   AA aa 44514   AA bb 43867   AA bb 44110   AA bb 44165   AA bb 44428   BB aa 43975   BB aa 44077   BB aa 44325   BB aa 44338   BB aa 44344   BB aa 44490   BB bb 43897   BB bb 43945   BB bb 43951   BB bb 44026   BB bb 44032   BB bb 44104   CC aa 43978   CC aa 44130   CC aa 44307   CC aa 44579   CC bb 43915   CC bb 44391   DD aa 43892   DD aa 44481   DD aa 44513   DD bb 43778   DD bb 43943   DD bb 44021   DD bb 44499   EE aa 43960   EE aa 44624   EE bb 43969   EE bb 44108   EE bb 44485   FF aa 44067   FF aa 44070   FF aa 44119   FF aa 44529   FF bb 43799   FF bb 43867   FF bb 44011   FF bb 44163   FF bb 44442   FF bb 44635   GG aa 44103   GG aa 44257   GG aa 44402   GG aa 44589   GG bb 43799   GG bb 43808   GG bb 43893   GG bb 44577   HH aa 43758   HH aa 43947   HH aa 44257   HH bb 43774   HH bb 44007   HH bb 44054   HH bb 44382   HH bb 44407   HH bb 44604   II aa 44085   II aa 44339   II bb 43932   II bb 44066   II bb 44294   II bb 44316   II bb 44487   JJ aa 43838   JJ aa 43969   JJ aa 44503   JJ aa 44624   JJ bb 43898   JJ bb 44383   JJ bb 44401   JJ bb 44480}

do_execsql_test 1.4.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803   AA aa 43826   AA aa 44498   AA aa 44514   AA bb 43867   AA bb 44110   AA bb 44165   AA bb 44428   BB aa 43975   BB aa 44077   BB aa 44325   BB aa 44338   BB aa 44344   BB aa 44490   BB bb 43897   BB bb 43945   BB bb 43951   BB bb 44026   BB bb 44032   BB bb 44104   CC aa 43978   CC aa 44130   CC aa 44307   CC aa 44579   CC bb 43915   CC bb 44391   DD aa 43892   DD aa 44481   DD aa 44513   DD bb 43778   DD bb 43943   DD bb 44021   DD bb 44499   EE aa 43960   EE aa 44624   EE bb 43969   EE bb 44108   EE bb 44485   FF aa 44067   FF aa 44070   FF aa 44119   FF aa 44529   FF bb 43799   FF bb 43867   FF bb 44011   FF bb 44163   FF bb 44442   FF bb 44635   GG aa 44103   GG aa 44257   GG aa 44402   GG aa 44589   GG bb 43799   GG bb 43808   GG bb 43893   GG bb 44577   HH aa 43758   HH aa 43947   HH aa 44257   HH bb 43774   HH bb 44007   HH bb 44054   HH bb 44382   HH bb 44407   HH bb 44604   II aa 44085   II aa 44339   II bb 43932   II bb 44066   II bb 44294   II bb 44316   II bb 44487   JJ aa 43838   JJ aa 43969   JJ aa 44503   JJ aa 44624   JJ bb 43898   JJ bb 44383   JJ bb 44401   JJ bb 44480}

do_execsql_test 1.5.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.5.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.5.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.5.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.5.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.6.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   CC aa 12025   CC aa 12025   CC aa 12025   CC aa 12025   CC bb 12025   CC bb 12025   DD aa 10462   DD aa 10462   DD aa 10462   DD bb 10462   DD bb 10462   DD bb 10462   DD bb 10462   EE aa 7154   EE aa 7154   EE bb 7154   EE bb 7154   EE bb 7154   FF aa 6571   FF aa 6571   FF aa 6571   FF aa 6571   FF bb 6571   FF bb 6571   FF bb 6571   FF bb 6571   FF bb 6571   FF bb 6571   GG aa 8207   GG aa 8207   GG aa 8207   GG aa 8207   GG bb 8207   GG bb 8207   GG bb 8207   GG bb 8207   HH aa 10136   HH aa 10136   HH aa 10136   HH bb 10136   HH bb 10136   HH bb 10136   HH bb 10136   HH bb 10136   HH bb 10136   II aa 9911   II aa 9911   II bb 9911   II bb 9911   II bb 9911   II bb 9911   II bb 9911   JJ aa 9083   JJ aa 9083   JJ aa 9083   JJ aa 9083   JJ bb 9083   JJ bb 9083   JJ bb 9083   JJ bb 9083}

do_execsql_test 1.6.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 2307   AA bb 2307   AA bb 2307   AA bb 2307   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 5251   BB bb 5251   BB bb 5251   BB bb 5251   BB bb 5251   BB bb 5251   CC aa 7340   CC aa 7340   CC aa 7340   CC aa 7340   CC bb 6421   CC bb 6421   DD aa 3122   DD aa 3122   DD aa 3122   DD bb 2493   DD bb 2493   DD bb 2493   DD bb 2493   EE aa 4032   EE aa 4032   EE bb 3597   EE bb 3597   EE bb 3597   FF aa 2539   FF aa 2539   FF aa 2539   FF aa 2539   FF bb 3812   FF bb 3812   FF bb 3812   FF bb 3812   FF bb 3812   FF bb 3812   GG aa 5668   GG aa 5668   GG aa 5668   GG aa 5668   GG bb 5102   GG bb 5102   GG bb 5102   GG bb 5102   HH aa 4468   HH aa 4468   HH aa 4468   HH bb 5120   HH bb 5120   HH bb 5120   HH bb 5120   HH bb 5120   HH bb 5120   II aa 5443   II aa 5443   II bb 4244   II bb 4244   II bb 4244   II bb 4244   II bb 4244   JJ aa 3640   JJ aa 3640   JJ aa 3640   JJ aa 3640   JJ bb 4604   JJ bb 4604   JJ bb 4604   JJ bb 4604}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 870   BB bb 870   BB bb 870   BB bb 870   BB bb 870   BB bb 870   CC aa 840   CC aa 840   CC aa 840   CC aa 840   CC bb 840   CC bb 840   DD aa 822   DD aa 822   DD aa 822   DD bb 845   DD bb 845   DD bb 845   DD bb 845   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 777   FF aa 777   FF aa 777   FF aa 777   FF bb 768   FF bb 768   FF bb 768   FF bb 768   FF bb 768   FF bb 768   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 938   HH aa 938   HH aa 938   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 963   II bb 963   II bb 963   II bb 963   II bb 963   JJ aa 805   JJ aa 805   JJ aa 805   JJ aa 805   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.6.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 247   BB bb 247   BB bb 247   BB bb 247   BB bb 247   BB bb 247   CC aa 247   CC aa 247   CC aa 247   CC aa 247   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 224   DD bb 224   DD bb 224   DD bb 224   EE aa 224   EE aa 224   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 208   FF bb 208   FF bb 208   FF bb 208   FF bb 208   FF bb 208   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 148   HH aa 148   HH aa 148   HH bb 160   HH bb 160   HH bb 160   HH bb 160   HH bb 160   HH bb 160   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 250   JJ aa 250   JJ aa 250   JJ aa 250   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}

do_execsql_test 1.6.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   CC aa 12025   CC aa 12025   CC aa 12025   CC aa 12025   CC bb 12025   CC bb 12025   DD aa 10462   DD aa 10462   DD aa 10462   DD bb 10462   DD bb 10462   DD bb 10462   DD bb 10462   EE aa 7154   EE aa 7154   EE bb 7154   EE bb 7154   EE bb 7154   FF aa 6571   FF aa 6571   FF aa 6571   FF aa 6571   FF bb 6571   FF bb 6571   FF bb 6571   FF bb 6571   FF bb 6571   FF bb 6571   GG aa 8207   GG aa 8207   GG aa 8207   GG aa 8207   GG bb 8207   GG bb 8207   GG bb 8207   GG bb 8207   HH aa 10136   HH aa 10136   HH aa 10136   HH bb 10136   HH bb 10136   HH bb 10136   HH bb 10136   HH bb 10136   HH bb 10136   II aa 9911   II aa 9911   II bb 9911   II bb 9911   II bb 9911   II bb 9911   II bb 9911   JJ aa 9083   JJ aa 9083   JJ aa 9083   JJ aa 9083   JJ bb 9083   JJ bb 9083   JJ bb 9083   JJ bb 9083}

do_execsql_test 1.6.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 2307   AA bb 2307   AA bb 2307   AA bb 2307   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 5251   BB bb 5251   BB bb 5251   BB bb 5251   BB bb 5251   BB bb 5251   CC aa 7340   CC aa 7340   CC aa 7340   CC aa 7340   CC bb 6421   CC bb 6421   DD aa 3122   DD aa 3122   DD aa 3122   DD bb 2493   DD bb 2493   DD bb 2493   DD bb 2493   EE aa 4032   EE aa 4032   EE bb 3597   EE bb 3597   EE bb 3597   FF aa 2539   FF aa 2539   FF aa 2539   FF aa 2539   FF bb 3812   FF bb 3812   FF bb 3812   FF bb 3812   FF bb 3812   FF bb 3812   GG aa 5668   GG aa 5668   GG aa 5668   GG aa 5668   GG bb 5102   GG bb 5102   GG bb 5102   GG bb 5102   HH aa 4468   HH aa 4468   HH aa 4468   HH bb 5120   HH bb 5120   HH bb 5120   HH bb 5120   HH bb 5120   HH bb 5120   II aa 5443   II aa 5443   II bb 4244   II bb 4244   II bb 4244   II bb 4244   II bb 4244   JJ aa 3640   JJ aa 3640   JJ aa 3640   JJ aa 3640   JJ bb 4604   JJ bb 4604   JJ bb 4604   JJ bb 4604}

do_execsql_test 1.7.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   CC aa 12025   CC aa 12025   CC aa 12025   CC aa 12025   CC bb 12025   CC bb 12025   DD aa 15147   DD aa 15147   DD aa 15147   DD bb 15147   DD bb 15147   DD bb 15147   DD bb 15147   EE aa 14494   EE aa 14494   EE bb 14494   EE bb 14494   EE bb 14494   FF aa 9693   FF aa 9693   FF aa 9693   FF aa 9693   FF bb 9693   FF bb 9693   FF bb 9693   FF bb 9693   FF bb 9693   FF bb 9693   GG aa 12239   GG aa 12239   GG aa 12239   GG aa 12239   GG bb 12239   GG bb 12239   GG bb 12239   GG bb 12239   HH aa 12675   HH aa 12675   HH aa 12675   HH bb 12675   HH bb 12675   HH bb 12675   HH bb 12675   HH bb 12675   HH bb 12675   II aa 15579   II aa 15579   II bb 15579   II bb 15579   II bb 15579   II bb 15579   II bb 15579   JJ aa 13551   JJ aa 13551   JJ aa 13551   JJ aa 13551   JJ bb 13551   JJ bb 13551   JJ bb 13551   JJ bb 13551}

do_execsql_test 1.7.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 2307   AA bb 2307   AA bb 2307   AA bb 2307   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   CC aa 9718   CC aa 9718   CC aa 9718   CC aa 9718   CC bb 9294   CC bb 9294   DD aa 7589   DD aa 7589   DD aa 7589   DD bb 4447   DD bb 4447   DD bb 4447   DD bb 4447   EE aa 5200   EE aa 5200   EE bb 4922   EE bb 4922   EE bb 4922   FF aa 5246   FF aa 5246   FF aa 5246   FF aa 5246   FF bb 4702   FF bb 4702   FF bb 4702   FF bb 4702   FF bb 4702   FF bb 4702   GG aa 7317   GG aa 7317   GG aa 7317   GG aa 7317   GG bb 7265   GG bb 7265   GG bb 7265   GG bb 7265   HH aa 7973   HH aa 7973   HH aa 7973   HH bb 6717   HH bb 6717   HH bb 6717   HH bb 6717   HH bb 6717   HH bb 6717   II aa 8314   II aa 8314   II bb 6493   II bb 6493   II bb 6493   II bb 6493   II bb 6493   JJ aa 6834   JJ aa 6834   JJ aa 6834   JJ aa 6834   JJ bb 5654   JJ bb 5654   JJ bb 5654   JJ bb 5654}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 870   CC aa 870   CC aa 870   CC aa 870   CC bb 840   CC bb 840   DD aa 840   DD aa 840   DD aa 840   DD bb 845   DD bb 845   DD bb 845   DD bb 845   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 777   FF bb 777   FF bb 777   FF bb 777   FF bb 777   FF bb 777   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 938   HH aa 938   HH aa 938   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 963   JJ aa 963   JJ aa 963   JJ aa 963   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.7.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 247   CC aa 247   CC aa 247   CC aa 247   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 224   EE aa 224   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 148   HH bb 148   HH bb 148   HH bb 148   HH bb 148   HH bb 148   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 133   JJ aa 133   JJ aa 133   JJ aa 133   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}

do_execsql_test 1.7.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   BB bb 4685   CC aa 12025   CC aa 12025   CC aa 12025   CC aa 12025   CC bb 12025   CC bb 12025   DD aa 15147   DD aa 15147   DD aa 15147   DD bb 15147   DD bb 15147   DD bb 15147   DD bb 15147   EE aa 14494   EE aa 14494   EE bb 14494   EE bb 14494   EE bb 14494   FF aa 9693   FF aa 9693   FF aa 9693   FF aa 9693   FF bb 9693   FF bb 9693   FF bb 9693   FF bb 9693   FF bb 9693   FF bb 9693   GG aa 12239   GG aa 12239   GG aa 12239   GG aa 12239   GG bb 12239   GG bb 12239   GG bb 12239   GG bb 12239   HH aa 12675   HH aa 12675   HH aa 12675   HH bb 12675   HH bb 12675   HH bb 12675   HH bb 12675   HH bb 12675   HH bb 12675   II aa 15579   II aa 15579   II bb 15579   II bb 15579   II bb 15579   II bb 15579   II bb 15579   JJ aa 13551   JJ aa 13551   JJ aa 13551   JJ aa 13551   JJ bb 13551   JJ bb 13551   JJ bb 13551   JJ bb 13551}

do_execsql_test 1.7.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 2307   AA bb 2307   AA bb 2307   AA bb 2307   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB aa 4685   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   BB bb 7558   CC aa 9718   CC aa 9718   CC aa 9718   CC aa 9718   CC bb 9294   CC bb 9294   DD aa 7589   DD aa 7589   DD aa 7589   DD bb 4447   DD bb 4447   DD bb 4447   DD bb 4447   EE aa 5200   EE aa 5200   EE bb 4922   EE bb 4922   EE bb 4922   FF aa 5246   FF aa 5246   FF aa 5246   FF aa 5246   FF bb 4702   FF bb 4702   FF bb 4702   FF bb 4702   FF bb 4702   FF bb 4702   GG aa 7317   GG aa 7317   GG aa 7317   GG aa 7317   GG bb 7265   GG bb 7265   GG bb 7265   GG bb 7265   HH aa 7973   HH aa 7973   HH aa 7973   HH bb 6717   HH bb 6717   HH bb 6717   HH bb 6717   HH bb 6717   HH bb 6717   II aa 8314   II aa 8314   II bb 6493   II bb 6493   II bb 6493   II bb 6493   II bb 6493   JJ aa 6834   JJ aa 6834   JJ aa 6834   JJ aa 6834   JJ bb 5654   JJ bb 5654   JJ bb 5654   JJ bb 5654}

do_execsql_test 1.8.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 15147   CC bb 15147   DD aa 19179   DD aa 19179   DD aa 19179   DD bb 19179   DD bb 19179   DD bb 19179   DD bb 19179   EE aa 17033   EE aa 17033   EE bb 17033   EE bb 17033   EE bb 17033   FF aa 15361   FF aa 15361   FF aa 15361   FF aa 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   GG aa 16707   GG aa 16707   GG aa 16707   GG aa 16707   GG bb 16707   GG bb 16707   GG bb 16707   GG bb 16707   HH aa 18118   HH aa 18118   HH aa 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   II aa 19219   II aa 19219   II bb 19219   II bb 19219   II bb 19219   II bb 19219   II bb 19219   JJ aa 17351   JJ aa 17351   JJ aa 17351   JJ aa 17351   JJ bb 17351   JJ bb 17351   JJ bb 17351   JJ bb 17351}

do_execsql_test 1.8.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 11672   CC aa 11672   CC aa 11672   CC aa 11672   CC bb 10462   CC bb 10462   DD aa 8914   DD aa 8914   DD aa 8914   DD bb 7154   DD bb 7154   DD bb 7154   DD bb 7154   EE aa 6090   EE aa 6090   EE bb 6571   EE bb 6571   EE bb 6571   FF aa 7409   FF aa 7409   FF aa 7409   FF aa 7409   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   GG aa 8914   GG aa 8914   GG aa 8914   GG aa 8914   GG bb 10136   GG bb 10136   GG bb 10136   GG bb 10136   HH aa 10222   HH aa 10222   HH aa 10222   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   II aa 9364   II aa 9364   II bb 9083   II bb 9083   II bb 9083   II bb 9083   II bb 9083   JJ aa 8848   JJ aa 8848   JJ aa 8848   JJ aa 8848   JJ bb 7440   JJ bb 7440   JJ bb 7440   JJ bb 7440}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 870   CC aa 870   CC aa 870   CC aa 870   CC bb 840   CC bb 840   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 963   JJ aa 963   JJ aa 963   JJ aa 963   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.8.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}

do_execsql_test 1.8.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751   AA aa 3774   AA aa 4446   AA aa 4462   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 11263   BB aa 11365   BB aa 11613   BB aa 11626   BB aa 11632   BB aa 11778   BB bb 11185   BB bb 11233   BB bb 11239   BB bb 11314   BB bb 11320   BB bb 11392   CC aa 14388   CC aa 14540   CC aa 14717   CC aa 14989   CC bb 14325   CC bb 14801   DD aa 18334   DD aa 18923   DD aa 18955   DD bb 18220   DD bb 18385   DD bb 18463   DD bb 18941   EE aa 16256   EE aa 16920   EE bb 16265   EE bb 16404   EE bb 16781   FF aa 14691   FF aa 14694   FF aa 14743   FF aa 15153   FF bb 14423   FF bb 14491   FF bb 14635   FF bb 14787   FF bb 15066   FF bb 15259   GG aa 16073   GG aa 16227   GG aa 16372   GG aa 16559   GG bb 15769   GG bb 15778   GG bb 15863   GG bb 16547   HH aa 17139   HH aa 17328   HH aa 17638   HH bb 17155   HH bb 17388   HH bb 17435   HH bb 17763   HH bb 17788   HH bb 17985   II aa 18567   II aa 18821   II bb 18414   II bb 18548   II bb 18776   II bb 18798   II bb 18969   JJ aa 16452   JJ aa 16583   JJ aa 17117   JJ aa 17238   JJ bb 16512   JJ bb 16997   JJ bb 17015   JJ bb 17094}

do_execsql_test 1.8.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1373   AA aa 1396   AA aa 2068   AA aa 2084   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 6796   BB aa 6898   BB aa 7146   BB aa 7159   BB aa 7165   BB aa 7311   BB bb 11185   BB bb 11233   BB bb 11239   BB bb 11314   BB bb 11320   BB bb 11392   CC aa 10913   CC aa 11065   CC aa 11242   CC aa 11514   CC bb 9640   CC bb 10116   DD aa 8069   DD aa 8658   DD aa 8690   DD bb 6195   DD bb 6360   DD bb 6438   DD bb 6916   EE aa 5313   EE aa 5977   EE bb 5803   EE bb 5942   EE bb 6319   FF aa 6739   FF aa 6742   FF aa 6791   FF aa 7201   FF bb 7269   FF bb 7337   FF bb 7481   FF bb 7633   FF bb 7912   FF bb 8105   GG aa 8280   GG aa 8434   GG aa 8579   GG aa 8766   GG bb 9198   GG bb 9207   GG bb 9292   GG bb 9976   HH aa 9243   HH aa 9432   HH aa 9742   HH bb 8948   HH bb 9181   HH bb 9228   HH bb 9556   HH bb 9581   HH bb 9778   II aa 8712   II aa 8966   II bb 8278   II bb 8412   II bb 8640   II bb 8662   II bb 8833   JJ aa 7949   JJ aa 8080   JJ aa 8614   JJ aa 8735   JJ bb 6601   JJ bb 7086   JJ bb 7104   JJ bb 7183}

do_execsql_test 1.9.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 15147   CC bb 15147   DD aa 14494   DD aa 14494   DD aa 14494   DD bb 14494   DD bb 14494   DD bb 14494   DD bb 14494   EE aa 9693   EE aa 9693   EE bb 9693   EE bb 9693   EE bb 9693   FF aa 12239   FF aa 12239   FF aa 12239   FF aa 12239   FF bb 12239   FF bb 12239   FF bb 12239   FF bb 12239   FF bb 12239   FF bb 12239   GG aa 12675   GG aa 12675   GG aa 12675   GG aa 12675   GG bb 12675   GG bb 12675   GG bb 12675   GG bb 12675   HH aa 15579   HH aa 15579   HH aa 15579   HH bb 15579   HH bb 15579   HH bb 15579   HH bb 15579   HH bb 15579   HH bb 15579   II aa 13551   II aa 13551   II bb 13551   II bb 13551   II bb 13551   II bb 13551   II bb 13551   JJ aa 12883   JJ aa 12883   JJ aa 12883   JJ aa 12883   JJ bb 12883   JJ bb 12883   JJ bb 12883   JJ bb 12883}

do_execsql_test 1.9.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB bb 9718   BB bb 9718   BB bb 9718   BB bb 9718   BB bb 9718   BB bb 9718   CC aa 9294   CC aa 9294   CC aa 9294   CC aa 9294   CC bb 7589   CC bb 7589   DD aa 4447   DD aa 4447   DD aa 4447   DD bb 5200   DD bb 5200   DD bb 5200   DD bb 5200   EE aa 4922   EE aa 4922   EE bb 5246   EE bb 5246   EE bb 5246   FF aa 4702   FF aa 4702   FF aa 4702   FF aa 4702   FF bb 7317   FF bb 7317   FF bb 7317   FF bb 7317   FF bb 7317   FF bb 7317   GG aa 7265   GG aa 7265   GG aa 7265   GG aa 7265   GG bb 7973   GG bb 7973   GG bb 7973   GG bb 7973   HH aa 6717   HH aa 6717   HH aa 6717   HH bb 8314   HH bb 8314   HH bb 8314   HH bb 8314   HH bb 8314   HH bb 8314   II aa 6493   II aa 6493   II bb 6834   II bb 6834   II bb 6834   II bb 6834   II bb 6834   JJ aa 5654   JJ aa 5654   JJ aa 5654   JJ aa 5654   JJ bb 6390   JJ bb 6390   JJ bb 6390   JJ bb 6390}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 870   BB bb 870   BB bb 870   BB bb 870   BB bb 870   BB bb 870   CC aa 840   CC aa 840   CC aa 840   CC aa 840   CC bb 840   CC bb 840   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 777   FF aa 777   FF aa 777   FF aa 777   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 963   II bb 963   II bb 963   II bb 963   II bb 963   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.9.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 247   BB bb 247   BB bb 247   BB bb 247   BB bb 247   BB bb 247   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 224   DD bb 224   DD bb 224   DD bb 224   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 148   HH aa 148   HH aa 148   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}

do_execsql_test 1.9.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751   AA aa 3774   AA aa 4446   AA aa 4462   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 11263   BB aa 11365   BB aa 11613   BB aa 11626   BB aa 11632   BB aa 11778   BB bb 11185   BB bb 11233   BB bb 11239   BB bb 11314   BB bb 11320   BB bb 11392   CC aa 14388   CC aa 14540   CC aa 14717   CC aa 14989   CC bb 14325   CC bb 14801   DD aa 13649   DD aa 14238   DD aa 14270   DD bb 13535   DD bb 13700   DD bb 13778   DD bb 14256   EE aa 8916   EE aa 9580   EE bb 8925   EE bb 9064   EE bb 9441   FF aa 11569   FF aa 11572   FF aa 11621   FF aa 12031   FF bb 11301   FF bb 11369   FF bb 11513   FF bb 11665   FF bb 11944   FF bb 12137   GG aa 12041   GG aa 12195   GG aa 12340   GG aa 12527   GG bb 11737   GG bb 11746   GG bb 11831   GG bb 12515   HH aa 14600   HH aa 14789   HH aa 15099   HH bb 14616   HH bb 14849   HH bb 14896   HH bb 15224   HH bb 15249   HH bb 15446   II aa 12899   II aa 13153   II bb 12746   II bb 12880   II bb 13108   II bb 13130   II bb 13301   JJ aa 11984   JJ aa 12115   JJ aa 12649   JJ aa 12770   JJ bb 12044   JJ bb 12529   JJ bb 12547   JJ bb 12626}

do_execsql_test 1.9.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1373   AA aa 1396   AA aa 2068   AA aa 2084   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 6796   BB aa 6898   BB aa 7146   BB aa 7159   BB aa 7165   BB aa 7311   BB bb 8878   BB bb 8926   BB bb 8932   BB bb 9007   BB bb 9013   BB bb 9085   CC aa 8535   CC aa 8687   CC aa 8864   CC aa 9136   CC bb 6767   CC bb 7243   DD aa 3602   DD aa 4191   DD aa 4223   DD bb 4241   DD bb 4406   DD bb 4484   DD bb 4962   EE aa 4145   EE aa 4809   EE bb 4478   EE bb 4617   EE bb 4994   FF aa 4032   FF aa 4035   FF aa 4084   FF aa 4494   FF bb 6379   FF bb 6447   FF bb 6591   FF bb 6743   FF bb 7022   FF bb 7215   GG aa 6631   GG aa 6785   GG aa 6930   GG aa 7117   GG bb 7035   GG bb 7044   GG bb 7129   GG bb 7813   HH aa 5738   HH aa 5927   HH aa 6237   HH bb 7351   HH bb 7584   HH bb 7631   HH bb 7959   HH bb 7984   HH bb 8181   II aa 5841   II aa 6095   II bb 6029   II bb 6163   II bb 6391   II bb 6413   II bb 6584   JJ aa 4755   JJ aa 4886   JJ aa 5420   JJ aa 5541   JJ bb 5551   JJ bb 6036   JJ bb 6054   JJ bb 6133}

do_execsql_test 1.10.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB aa 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 15147   CC aa 15147   CC aa 15147   CC aa 15147   CC bb 15147   CC bb 15147   DD aa 19179   DD aa 19179   DD aa 19179   DD bb 19179   DD bb 19179   DD bb 19179   DD bb 19179   EE aa 17033   EE aa 17033   EE bb 17033   EE bb 17033   EE bb 17033   FF aa 15361   FF aa 15361   FF aa 15361   FF aa 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   FF bb 15361   GG aa 16707   GG aa 16707   GG aa 16707   GG aa 16707   GG bb 16707   GG bb 16707   GG bb 16707   GG bb 16707   HH aa 18118   HH aa 18118   HH aa 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   HH bb 18118   II aa 19219   II aa 19219   II bb 19219   II bb 19219   II bb 19219   II bb 19219   II bb 19219   JJ aa 17351   JJ aa 17351   JJ aa 17351   JJ aa 17351   JJ bb 17351   JJ bb 17351   JJ bb 17351   JJ bb 17351}

do_execsql_test 1.10.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB aa 7558   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   BB bb 12025   CC aa 11672   CC aa 11672   CC aa 11672   CC aa 11672   CC bb 10462   CC bb 10462   DD aa 8914   DD aa 8914   DD aa 8914   DD bb 7154   DD bb 7154   DD bb 7154   DD bb 7154   EE aa 6090   EE aa 6090   EE bb 6571   EE bb 6571   EE bb 6571   FF aa 7409   FF aa 7409   FF aa 7409   FF aa 7409   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   FF bb 8207   GG aa 8914   GG aa 8914   GG aa 8914   GG aa 8914   GG bb 10136   GG bb 10136   GG bb 10136   GG bb 10136   HH aa 10222   HH aa 10222   HH aa 10222   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   HH bb 9911   II aa 9364   II aa 9364   II bb 9083   II bb 9083   II bb 9083   II bb 9083   II bb 9083   JJ aa 8848   JJ aa 8848   JJ aa 8848   JJ aa 8848   JJ bb 7440   JJ bb 7440   JJ bb 7440   JJ bb 7440}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934   AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934   CC aa 870   CC aa 870   CC aa 870   CC aa 870   CC bb 840   CC bb 840   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959   EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979   JJ aa 963   JJ aa 963   JJ aa 963   JJ aa 963   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.10.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 223   AA bb 223   AA bb 223   AA bb 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB aa 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   BB bb 223   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 158   CC bb 158   DD aa 158   DD aa 158   DD aa 158   DD bb 158   DD bb 158   DD bb 158   DD bb 158   EE aa 113   EE aa 113   EE bb 113   EE bb 113   EE bb 113   FF aa 113   FF aa 113   FF aa 113   FF aa 113   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 102   HH aa 102   HH aa 102   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 133   II aa 133   II bb 133   II bb 133   II bb 133   II bb 133   II bb 133   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}

do_execsql_test 1.10.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751   AA aa 3774   AA aa 4446   AA aa 4462   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 11263   BB aa 11365   BB aa 11613   BB aa 11626   BB aa 11632   BB aa 11778   BB bb 11185   BB bb 11233   BB bb 11239   BB bb 11314   BB bb 11320   BB bb 11392   CC aa 14388   CC aa 14540   CC aa 14717   CC aa 14989   CC bb 14325   CC bb 14801   DD aa 18334   DD aa 18923   DD aa 18955   DD bb 18220   DD bb 18385   DD bb 18463   DD bb 18941   EE aa 16256   EE aa 16920   EE bb 16265   EE bb 16404   EE bb 16781   FF aa 14691   FF aa 14694   FF aa 14743   FF aa 15153   FF bb 14423   FF bb 14491   FF bb 14635   FF bb 14787   FF bb 15066   FF bb 15259   GG aa 16073   GG aa 16227   GG aa 16372   GG aa 16559   GG bb 15769   GG bb 15778   GG bb 15863   GG bb 16547   HH aa 17139   HH aa 17328   HH aa 17638   HH bb 17155   HH bb 17388   HH bb 17435   HH bb 17763   HH bb 17788   HH bb 17985   II aa 18567   II aa 18821   II bb 18414   II bb 18548   II bb 18776   II bb 18798   II bb 18969   JJ aa 16452   JJ aa 16583   JJ aa 17117   JJ aa 17238   JJ bb 16512   JJ bb 16997   JJ bb 17015   JJ bb 17094}

do_execsql_test 1.10.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1373   AA aa 1396   AA aa 2068   AA aa 2084   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 6796   BB aa 6898   BB aa 7146   BB aa 7159   BB aa 7165   BB aa 7311   BB bb 11185   BB bb 11233   BB bb 11239   BB bb 11314   BB bb 11320   BB bb 11392   CC aa 10913   CC aa 11065   CC aa 11242   CC aa 11514   CC bb 9640   CC bb 10116   DD aa 8069   DD aa 8658   DD aa 8690   DD bb 6195   DD bb 6360   DD bb 6438   DD bb 6916   EE aa 5313   EE aa 5977   EE bb 5803   EE bb 5942   EE bb 6319   FF aa 6739   FF aa 6742   FF aa 6791   FF aa 7201   FF bb 7269   FF bb 7337   FF bb 7481   FF bb 7633   FF bb 7912   FF bb 8105   GG aa 8280   GG aa 8434   GG aa 8579   GG aa 8766   GG bb 9198   GG bb 9207   GG bb 9292   GG bb 9976   HH aa 9243   HH aa 9432   HH aa 9742   HH bb 8948   HH bb 9181   HH bb 9228   HH bb 9556   HH bb 9581   HH bb 9778   II aa 8712   II aa 8966   II bb 8278   II bb 8412   II bb 8640   II bb 8662   II bb 8833   JJ aa 7949   JJ aa 8080   JJ aa 8614   JJ aa 8735   JJ bb 6601   JJ bb 7086   JJ bb 7104   JJ bb 7183}

do_execsql_test 1.11.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   BB bb 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC aa 44737   CC bb 44737   CC bb 44737   DD aa 40052   DD aa 40052   DD aa 40052   DD bb 40052   DD bb 40052   DD bb 40052   DD bb 40052   EE aa 32712   EE aa 32712   EE bb 32712   EE bb 32712   EE bb 32712   FF aa 29590   FF aa 29590   FF aa 29590   FF aa 29590   FF bb 29590   FF bb 29590   FF bb 29590   FF bb 29590   FF bb 29590   FF bb 29590   GG aa 25558   GG aa 25558   GG aa 25558   GG aa 25558   GG bb 25558   GG bb 25558   GG bb 25558   GG bb 25558   HH aa 23019   HH aa 23019   HH aa 23019   HH bb 23019   HH bb 23019   HH bb 23019   HH bb 23019   HH bb 23019   HH bb 23019   II aa 17351   II aa 17351   II bb 17351   II bb 17351   II bb 17351   II bb 17351   II bb 17351   JJ aa 12883   JJ aa 12883   JJ aa 12883   JJ aa 12883   JJ bb 12883   JJ bb 12883   JJ bb 12883   JJ bb 12883}

do_execsql_test 1.11.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB aa 44737   BB bb 42430   BB bb 42430   BB bb 42430   BB bb 42430   BB bb 42430   BB bb 42430   CC aa 40052   CC aa 40052   CC aa 40052   CC aa 40052   CC bb 37179   CC bb 37179   DD aa 32712   DD aa 32712   DD aa 32712   DD bb 30758   DD bb 30758   DD bb 30758   DD bb 30758   EE aa 29590   EE aa 29590   EE bb 28265   EE bb 28265   EE bb 28265   FF aa 25558   FF aa 25558   FF aa 25558   FF aa 25558   FF bb 24668   FF bb 24668   FF bb 24668   FF bb 24668   FF bb 24668   FF bb 24668   GG aa 23019   GG aa 23019   GG aa 23019   GG aa 23019   GG bb 20856   GG bb 20856   GG bb 20856   GG bb 20856   HH aa 17351   HH aa 17351   HH aa 17351   HH bb 15754   HH bb 15754   HH bb 15754   HH bb 15754   HH bb 15754   HH bb 15754   II aa 12883   II aa 12883   II bb 10634   II bb 10634   II bb 10634   II bb 10634   II bb 10634   JJ aa 7440   JJ aa 7440   JJ aa 7440   JJ aa 7440   JJ bb 6390   JJ bb 6390   JJ bb 6390   JJ bb 6390}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979   II aa 979   II bb 963   II bb 963   II bb 963   II bb 963   II bb 963   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 899   JJ bb 899   JJ bb 899   JJ bb 899}

do_execsql_test 1.11.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 102   GG aa 102   GG aa 102   GG aa 102   GG bb 102   GG bb 102   GG bb 102   GG bb 102   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 113   JJ bb 113   JJ bb 113   JJ bb 113}

do_execsql_test 1.11.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803   AA aa 43826   AA aa 44498   AA aa 44514   AA bb 43867   AA bb 44110   AA bb 44165   AA bb 44428   BB aa 43975   BB aa 44077   BB aa 44325   BB aa 44338   BB aa 44344   BB aa 44490   BB bb 43897   BB bb 43945   BB bb 43951   BB bb 44026   BB bb 44032   BB bb 44104   CC aa 43978   CC aa 44130   CC aa 44307   CC aa 44579   CC bb 43915   CC bb 44391   DD aa 39207   DD aa 39796   DD aa 39828   DD bb 39093   DD bb 39258   DD bb 39336   DD bb 39814   EE aa 31935   EE aa 32599   EE bb 31944   EE bb 32083   EE bb 32460   FF aa 28920   FF aa 28923   FF aa 28972   FF aa 29382   FF bb 28652   FF bb 28720   FF bb 28864   FF bb 29016   FF bb 29295   FF bb 29488   GG aa 24924   GG aa 25078   GG aa 25223   GG aa 25410   GG bb 24620   GG bb 24629   GG bb 24714   GG bb 25398   HH aa 22040   HH aa 22229   HH aa 22539   HH bb 22056   HH bb 22289   HH bb 22336   HH bb 22664   HH bb 22689   HH bb 22886   II aa 16699   II aa 16953   II bb 16546   II bb 16680   II bb 16908   II bb 16930   II bb 17101   JJ aa 11984   JJ aa 12115   JJ aa 12649   JJ aa 12770   JJ bb 12044   JJ bb 12529   JJ bb 12547   JJ bb 12626}

do_execsql_test 1.11.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803   AA aa 43826   AA aa 44498   AA aa 44514   AA bb 43867   AA bb 44110   AA bb 44165   AA bb 44428   BB aa 43975   BB aa 44077   BB aa 44325   BB aa 44338   BB aa 44344   BB aa 44490   BB bb 41590   BB bb 41638   BB bb 41644   BB bb 41719   BB bb 41725   BB bb 41797   CC aa 39293   CC aa 39445   CC aa 39622   CC aa 39894   CC bb 36357   CC bb 36833   DD aa 31867   DD aa 32456   DD aa 32488   DD bb 29799   DD bb 29964   DD bb 30042   DD bb 30520   EE aa 28813   EE aa 29477   EE bb 27497   EE bb 27636   EE bb 28013   FF aa 24888   FF aa 24891   FF aa 24940   FF aa 25350   FF bb 23730   FF bb 23798   FF bb 23942   FF bb 24094   FF bb 24373   FF bb 24566   GG aa 22385   GG aa 22539   GG aa 22684   GG aa 22871   GG bb 19918   GG bb 19927   GG bb 20012   GG bb 20696   HH aa 16372   HH aa 16561   HH aa 16871   HH bb 14791   HH bb 15024   HH bb 15071   HH bb 15399   HH bb 15424   HH bb 15621   II aa 12231   II aa 12485   II bb 9829   II bb 9963   II bb 10191   II bb 10213   II bb 10384   JJ aa 6541   JJ aa 6672   JJ aa 7206   JJ aa 7327   JJ bb 5551   JJ bb 6036   JJ bb 6054   JJ bb 6133}

do_execsql_test 1.12.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   CC aa 3122   CC aa 3122   CC aa 3122   CC aa 3122   CC bb 3122   CC bb 3122   DD aa 4032   DD aa 4032   DD aa 4032   DD bb 4032   DD bb 4032   DD bb 4032   DD bb 4032   EE aa 2539   EE aa 2539   EE bb 2539   EE bb 2539   EE bb 2539   FF aa 5668   FF aa 5668   FF aa 5668   FF aa 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   GG aa 4468   GG aa 4468   GG aa 4468   GG aa 4468   GG bb 4468   GG bb 4468   GG bb 4468   GG bb 4468   HH aa 5443   HH aa 5443   HH aa 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   II aa 3640   II aa 3640   II bb 3640   II bb 3640   II bb 3640   II bb 3640   II bb 3640   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.12.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 2378   AA bb 2378   AA bb 2378   AA bb 2378   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   CC aa 1954   CC aa 1954   CC aa 1954   CC aa 1954   CC bb 1168   CC bb 1168   DD aa 1325   DD aa 1325   DD aa 1325   DD bb 2707   DD bb 2707   DD bb 2707   DD bb 2707   EE aa 890   EE aa 890   EE bb 1649   EE bb 1649   EE bb 1649   FF aa 2163   FF aa 2163   FF aa 2163   FF aa 2163   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   GG aa 1597   GG aa 1597   GG aa 1597   GG aa 1597   GG bb 2871   GG bb 2871   GG bb 2871   GG bb 2871   HH aa 2249   HH aa 2249   HH aa 2249   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   II aa 1050   II aa 1050   II bb 2590   II bb 2590   II bb 2590   II bb 2590   II bb 2590   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 870   AA bb 870   AA bb 870   AA bb 870   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   CC aa 759   CC aa 759   CC aa 759   CC aa 759   CC bb 822   CC bb 822   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 777   EE aa 777   EE bb 768   EE bb 768   EE bb 768   FF aa 670   FF aa 670   FF aa 670   FF aa 670   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 634   GG aa 634   GG aa 634   GG aa 634   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 652   II aa 652   II bb 805   II bb 805   II bb 805   II bb 805   II bb 805   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.12.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 309   AA bb 309   AA bb 309   AA bb 309   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB bb 633   BB bb 633   BB bb 633   BB bb 633   BB bb 633   BB bb 633   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 346   CC bb 346   DD aa 224   DD aa 224   DD aa 224   DD bb 238   DD bb 238   DD bb 238   DD bb 238   EE aa 113   EE aa 113   EE bb 252   EE bb 252   EE bb 252   FF aa 208   FF aa 208   FF aa 208   FF aa 208   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 148   GG aa 148   GG aa 148   GG aa 148   GG bb 160   GG bb 160   GG bb 160   GG bb 160   HH aa 480   HH aa 480   HH aa 480   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 398   II aa 398   II bb 250   II bb 250   II bb 250   II bb 250   II bb 250   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}

do_execsql_test 1.12.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751   AA aa 3774   AA aa 4446   AA aa 4462   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 6578   BB aa 6680   BB aa 6928   BB aa 6941   BB aa 6947   BB aa 7093   BB bb 6500   BB bb 6548   BB bb 6554   BB bb 6629   BB bb 6635   BB bb 6707   CC aa 2363   CC aa 2515   CC aa 2692   CC aa 2964   CC bb 2300   CC bb 2776   DD aa 3187   DD aa 3776   DD aa 3808   DD bb 3073   DD bb 3238   DD bb 3316   DD bb 3794   EE aa 1762   EE aa 2426   EE bb 1771   EE bb 1910   EE bb 2287   FF aa 4998   FF aa 5001   FF aa 5050   FF aa 5460   FF bb 4730   FF bb 4798   FF bb 4942   FF bb 5094   FF bb 5373   FF bb 5566   GG aa 3834   GG aa 3988   GG aa 4133   GG aa 4320   GG bb 3530   GG bb 3539   GG bb 3624   GG bb 4308   HH aa 4464   HH aa 4653   HH aa 4963   HH bb 4480   HH bb 4713   HH bb 4760   HH bb 5088   HH bb 5113   HH bb 5310   II aa 2988   II aa 3242   II bb 2835   II bb 2969   II bb 3197   II bb 3219   II bb 3390   JJ aa 2901   JJ aa 3032   JJ aa 3566   JJ aa 3687   JJ bb 2961   JJ bb 3446   JJ bb 3464   JJ bb 3543}

do_execsql_test 1.12.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1373   AA aa 1396   AA aa 2068   AA aa 2084   AA bb 1508   AA bb 1751   AA bb 1806   AA bb 2069   BB aa 2111   BB aa 2213   BB aa 2461   BB aa 2474   BB aa 2480   BB aa 2626   BB bb 3627   BB bb 3675   BB bb 3681   BB bb 3756   BB bb 3762   BB bb 3834   CC aa 1195   CC aa 1347   CC aa 1524   CC aa 1796   CC bb 346   CC bb 822   DD aa 480   DD aa 1069   DD aa 1101   DD bb 1748   DD bb 1913   DD bb 1991   DD bb 2469   EE aa 113   EE aa 777   EE bb 881   EE bb 1020   EE bb 1397   FF aa 1493   FF aa 1496   FF aa 1545   FF aa 1955   FF bb 2567   FF bb 2635   FF bb 2779   FF bb 2931   FF bb 3210   FF bb 3403   GG aa 963   GG aa 1117   GG aa 1262   GG aa 1449   GG bb 1933   GG bb 1942   GG bb 2027   GG bb 2711   HH aa 1270   HH aa 1459   HH aa 1769   HH bb 2231   HH bb 2464   HH bb 2511   HH bb 2839   HH bb 2864   HH bb 3061   II aa 398   II aa 652   II bb 1785   II bb 1919   II bb 2147   II bb 2169   II bb 2340   JJ aa 1115   JJ aa 1246   JJ aa 1780   JJ aa 1901   JJ bb 947   JJ bb 1432   JJ bb 1450   JJ bb 1529}

do_execsql_test 1.13.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 12025   AA aa 12025   AA aa 12025   AA aa 12025   AA bb 12025   AA bb 12025   AA bb 12025   AA bb 12025   BB aa 10462   BB aa 10462   BB aa 10462   BB aa 10462   BB aa 10462   BB aa 10462   BB bb 10462   BB bb 10462   BB bb 10462   BB bb 10462   BB bb 10462   BB bb 10462   CC aa 7154   CC aa 7154   CC aa 7154   CC aa 7154   CC bb 7154   CC bb 7154   DD aa 6571   DD aa 6571   DD aa 6571   DD bb 6571   DD bb 6571   DD bb 6571   DD bb 6571   EE aa 8207   EE aa 8207   EE bb 8207   EE bb 8207   EE bb 8207   FF aa 10136   FF aa 10136   FF aa 10136   FF aa 10136   FF bb 10136   FF bb 10136   FF bb 10136   FF bb 10136   FF bb 10136   FF bb 10136   GG aa 9911   GG aa 9911   GG aa 9911   GG aa 9911   GG bb 9911   GG bb 9911   GG bb 9911   GG bb 9911   HH aa 9083   HH aa 9083   HH aa 9083   HH bb 9083   HH bb 9083   HH bb 9083   HH bb 9083   HH bb 9083   HH bb 9083   II aa 7440   II aa 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.13.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 5251   AA bb 5251   AA bb 5251   AA bb 5251   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB bb 6421   BB bb 6421   BB bb 6421   BB bb 6421   BB bb 6421   BB bb 6421   CC aa 3122   CC aa 3122   CC aa 3122   CC aa 3122   CC bb 2493   CC bb 2493   DD aa 4032   DD aa 4032   DD aa 4032   DD bb 3597   DD bb 3597   DD bb 3597   DD bb 3597   EE aa 2539   EE aa 2539   EE bb 3812   EE bb 3812   EE bb 3812   FF aa 5668   FF aa 5668   FF aa 5668   FF aa 5668   FF bb 5102   FF bb 5102   FF bb 5102   FF bb 5102   FF bb 5102   FF bb 5102   GG aa 4468   GG aa 4468   GG aa 4468   GG aa 4468   GG bb 5120   GG bb 5120   GG bb 5120   GG bb 5120   HH aa 5443   HH aa 5443   HH aa 5443   HH bb 4244   HH bb 4244   HH bb 4244   HH bb 4244   HH bb 4244   HH bb 4244   II aa 3640   II aa 3640   II bb 4604   II bb 4604   II bb 4604   II bb 4604   II bb 4604   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 870   AA bb 870   AA bb 870   AA bb 870   BB aa 840   BB aa 840   BB aa 840   BB aa 840   BB aa 840   BB aa 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   CC aa 822   CC aa 822   CC aa 822   CC aa 822   CC bb 845   CC bb 845   DD aa 959   DD aa 959   DD aa 959   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 777   EE aa 777   EE bb 768   EE bb 768   EE bb 768   FF aa 938   FF aa 938   FF aa 938   FF aa 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 805   II aa 805   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.13.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 247   AA bb 247   AA bb 247   AA bb 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB bb 158   BB bb 158   BB bb 158   BB bb 158   BB bb 158   BB bb 158   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 224   CC bb 224   DD aa 224   DD aa 224   DD aa 224   DD bb 113   DD bb 113   DD bb 113   DD bb 113   EE aa 113   EE aa 113   EE bb 208   EE bb 208   EE bb 208   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 148   GG aa 148   GG aa 148   GG aa 148   GG bb 160   GG bb 160   GG bb 160   GG bb 160   HH aa 133   HH aa 133   HH aa 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 250   II aa 250   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}

do_execsql_test 1.13.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 11091   AA aa 11114   AA aa 11786   AA aa 11802   AA bb 11155   AA bb 11398   AA bb 11453   AA bb 11716   BB aa 9700   BB aa 9802   BB aa 10050   BB aa 10063   BB aa 10069   BB aa 10215   BB bb 9622   BB bb 9670   BB bb 9676   BB bb 9751   BB bb 9757   BB bb 9829   CC aa 6395   CC aa 6547   CC aa 6724   CC aa 6996   CC bb 6332   CC bb 6808   DD aa 5726   DD aa 6315   DD aa 6347   DD bb 5612   DD bb 5777   DD bb 5855   DD bb 6333   EE aa 7430   EE aa 8094   EE bb 7439   EE bb 7578   EE bb 7955   FF aa 9466   FF aa 9469   FF aa 9518   FF aa 9928   FF bb 9198   FF bb 9266   FF bb 9410   FF bb 9562   FF bb 9841   FF bb 10034   GG aa 9277   GG aa 9431   GG aa 9576   GG aa 9763   GG bb 8973   GG bb 8982   GG bb 9067   GG bb 9751   HH aa 8104   HH aa 8293   HH aa 8603   HH bb 8120   HH bb 8353   HH bb 8400   HH bb 8728   HH bb 8753   HH bb 8950   II aa 6788   II aa 7042   II bb 6635   II bb 6769   II bb 6997   II bb 7019   II bb 7190   JJ aa 2901   JJ aa 3032   JJ aa 3566   JJ aa 3687   JJ bb 2961   JJ bb 3446   JJ bb 3464   JJ bb 3543}

do_execsql_test 1.13.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751   AA aa 3774   AA aa 4446   AA aa 4462   AA bb 4381   AA bb 4624   AA bb 4679   AA bb 4942   BB aa 6578   BB aa 6680   BB aa 6928   BB aa 6941   BB aa 6947   BB aa 7093   BB bb 5581   BB bb 5629   BB bb 5635   BB bb 5710   BB bb 5716   BB bb 5788   CC aa 2363   CC aa 2515   CC aa 2692   CC aa 2964   CC bb 1671   CC bb 2147   DD aa 3187   DD aa 3776   DD aa 3808   DD bb 2638   DD bb 2803   DD bb 2881   DD bb 3359   EE aa 1762   EE aa 2426   EE bb 3044   EE bb 3183   EE bb 3560   FF aa 4998   FF aa 5001   FF aa 5050   FF aa 5460   FF bb 4164   FF bb 4232   FF bb 4376   FF bb 4528   FF bb 4807   FF bb 5000   GG aa 3834   GG aa 3988   GG aa 4133   GG aa 4320   GG bb 4182   GG bb 4191   GG bb 4276   GG bb 4960   HH aa 4464   HH aa 4653   HH aa 4963   HH bb 3281   HH bb 3514   HH bb 3561   HH bb 3889   HH bb 3914   HH bb 4111   II aa 2988   II aa 3242   II bb 3799   II bb 3933   II bb 4161   II bb 4183   II bb 4354   JJ aa 2901   JJ aa 3032   JJ aa 3566   JJ aa 3687   JJ bb 947   JJ bb 1432   JJ bb 1450   JJ bb 1529}

do_execsql_test 1.14.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   CC aa 32712   CC aa 32712   CC aa 32712   CC aa 32712   CC bb 32712   CC bb 32712   DD aa 29590   DD aa 29590   DD aa 29590   DD bb 29590   DD bb 29590   DD bb 29590   DD bb 29590   EE aa 25558   EE aa 25558   EE bb 25558   EE bb 25558   EE bb 25558   FF aa 23019   FF aa 23019   FF aa 23019   FF aa 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   GG aa 17351   GG aa 17351   GG aa 17351   GG aa 17351   GG bb 17351   GG bb 17351   GG bb 17351   GG bb 17351   HH aa 12883   HH aa 12883   HH aa 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   II aa 7440   II aa 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.14.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 42430   AA bb 42430   AA bb 42430   AA bb 42430   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   CC aa 32712   CC aa 32712   CC aa 32712   CC aa 32712   CC bb 30758   CC bb 30758   DD aa 29590   DD aa 29590   DD aa 29590   DD bb 28265   DD bb 28265   DD bb 28265   DD bb 28265   EE aa 25558   EE aa 25558   EE bb 24668   EE bb 24668   EE bb 24668   FF aa 23019   FF aa 23019   FF aa 23019   FF aa 23019   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   GG aa 17351   GG aa 17351   GG aa 17351   GG aa 17351   GG bb 15754   GG bb 15754   GG bb 15754   GG bb 15754   HH aa 12883   HH aa 12883   HH aa 12883   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   II aa 7440   II aa 7440   II bb 6390   II bb 6390   II bb 6390   II bb 6390   II bb 6390   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 899   II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.14.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 113   GG aa 113   GG aa 113   GG aa 113   GG bb 113   GG bb 113   GG bb 113   GG bb 113   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}

do_execsql_test 1.14.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803   AA aa 43826   AA aa 44498   AA aa 44514   AA bb 43867   AA bb 44110   AA bb 44165   AA bb 44428   BB aa 39290   BB aa 39392   BB aa 39640   BB aa 39653   BB aa 39659   BB aa 39805   BB bb 39212   BB bb 39260   BB bb 39266   BB bb 39341   BB bb 39347   BB bb 39419   CC aa 31953   CC aa 32105   CC aa 32282   CC aa 32554   CC bb 31890   CC bb 32366   DD aa 28745   DD aa 29334   DD aa 29366   DD bb 28631   DD bb 28796   DD bb 28874   DD bb 29352   EE aa 24781   EE aa 25445   EE bb 24790   EE bb 24929   EE bb 25306   FF aa 22349   FF aa 22352   FF aa 22401   FF aa 22811   FF bb 22081   FF bb 22149   FF bb 22293   FF bb 22445   FF bb 22724   FF bb 22917   GG aa 16717   GG aa 16871   GG aa 17016   GG aa 17203   GG bb 16413   GG bb 16422   GG bb 16507   GG bb 17191   HH aa 11904   HH aa 12093   HH aa 12403   HH bb 11920   HH bb 12153   HH bb 12200   HH bb 12528   HH bb 12553   HH bb 12750   II aa 6788   II aa 7042   II bb 6635   II bb 6769   II bb 6997   II bb 7019   II bb 7190   JJ aa 2901   JJ aa 3032   JJ aa 3566   JJ aa 3687   JJ bb 2961   JJ bb 3446   JJ bb 3464   JJ bb 3543}

do_execsql_test 1.14.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803   AA aa 43826   AA aa 44498   AA aa 44514   AA bb 41560   AA bb 41803   AA bb 41858   AA bb 42121   BB aa 39290   BB aa 39392   BB aa 39640   BB aa 39653   BB aa 39659   BB aa 39805   BB bb 36339   BB bb 36387   BB bb 36393   BB bb 36468   BB bb 36474   BB bb 36546   CC aa 31953   CC aa 32105   CC aa 32282   CC aa 32554   CC bb 29936   CC bb 30412   DD aa 28745   DD aa 29334   DD aa 29366   DD bb 27306   DD bb 27471   DD bb 27549   DD bb 28027   EE aa 24781   EE aa 25445   EE bb 23900   EE bb 24039   EE bb 24416   FF aa 22349   FF aa 22352   FF aa 22401   FF aa 22811   FF bb 19918   FF bb 19986   FF bb 20130   FF bb 20282   FF bb 20561   FF bb 20754   GG aa 16717   GG aa 16871   GG aa 17016   GG aa 17203   GG bb 14816   GG bb 14825   GG bb 14910   GG bb 15594   HH aa 11904   HH aa 12093   HH aa 12403   HH bb 9671   HH bb 9904   HH bb 9951   HH bb 10279   HH bb 10304   HH bb 10501   II aa 6788   II aa 7042   II bb 5585   II bb 5719   II bb 5947   II bb 5969   II bb 6140   JJ aa 2901   JJ aa 3032   JJ aa 3566   JJ aa 3687   JJ bb 947   JJ bb 1432   JJ bb 1450   JJ bb 1529}

do_execsql_test 1.15.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 44737   AA bb 44737   AA bb 44737   AA bb 44737   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   BB bb 40052   CC aa 32712   CC aa 32712   CC aa 32712   CC aa 32712   CC bb 32712   CC bb 32712   DD aa 29590   DD aa 29590   DD aa 29590   DD bb 29590   DD bb 29590   DD bb 29590   DD bb 29590   EE aa 25558   EE aa 25558   EE bb 25558   EE bb 25558   EE bb 25558   FF aa 23019   FF aa 23019   FF aa 23019   FF aa 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   FF bb 23019   GG aa 17351   GG aa 17351   GG aa 17351   GG aa 17351   GG bb 17351   GG bb 17351   GG bb 17351   GG bb 17351   HH aa 12883   HH aa 12883   HH aa 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   HH bb 12883   II aa 7440   II aa 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   II bb 7440   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.15.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 44737   AA aa 44737   AA aa 44737   AA aa 44737   AA bb 42430   AA bb 42430   AA bb 42430   AA bb 42430   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB aa 40052   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   BB bb 37179   CC aa 32712   CC aa 32712   CC aa 32712   CC aa 32712   CC bb 30758   CC bb 30758   DD aa 29590   DD aa 29590   DD aa 29590   DD bb 28265   DD bb 28265   DD bb 28265   DD bb 28265   EE aa 25558   EE aa 25558   EE bb 24668   EE bb 24668   EE bb 24668   FF aa 23019   FF aa 23019   FF aa 23019   FF aa 23019   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   FF bb 20856   GG aa 17351   GG aa 17351   GG aa 17351   GG aa 17351   GG bb 15754   GG bb 15754   GG bb 15754   GG bb 15754   HH aa 12883   HH aa 12883   HH aa 12883   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   HH bb 10634   II aa 7440   II aa 7440   II bb 6390   II bb 6390   II bb 6390   II bb 6390   II bb 6390   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 899   II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.15.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 113   GG aa 113   GG aa 113   GG aa 113   GG bb 113   GG bb 113   GG bb 113   GG bb 113   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}

do_execsql_test 1.15.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803   AA aa 43826   AA aa 44498   AA aa 44514   AA bb 43867   AA bb 44110   AA bb 44165   AA bb 44428   BB aa 39290   BB aa 39392   BB aa 39640   BB aa 39653   BB aa 39659   BB aa 39805   BB bb 39212   BB bb 39260   BB bb 39266   BB bb 39341   BB bb 39347   BB bb 39419   CC aa 31953   CC aa 32105   CC aa 32282   CC aa 32554   CC bb 31890   CC bb 32366   DD aa 28745   DD aa 29334   DD aa 29366   DD bb 28631   DD bb 28796   DD bb 28874   DD bb 29352   EE aa 24781   EE aa 25445   EE bb 24790   EE bb 24929   EE bb 25306   FF aa 22349   FF aa 22352   FF aa 22401   FF aa 22811   FF bb 22081   FF bb 22149   FF bb 22293   FF bb 22445   FF bb 22724   FF bb 22917   GG aa 16717   GG aa 16871   GG aa 17016   GG aa 17203   GG bb 16413   GG bb 16422   GG bb 16507   GG bb 17191   HH aa 11904   HH aa 12093   HH aa 12403   HH bb 11920   HH bb 12153   HH bb 12200   HH bb 12528   HH bb 12553   HH bb 12750   II aa 6788   II aa 7042   II bb 6635   II bb 6769   II bb 6997   II bb 7019   II bb 7190   JJ aa 2901   JJ aa 3032   JJ aa 3566   JJ aa 3687   JJ bb 2961   JJ bb 3446   JJ bb 3464   JJ bb 3543}

do_execsql_test 1.15.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803   AA aa 43826   AA aa 44498   AA aa 44514   AA bb 41560   AA bb 41803   AA bb 41858   AA bb 42121   BB aa 39290   BB aa 39392   BB aa 39640   BB aa 39653   BB aa 39659   BB aa 39805   BB bb 36339   BB bb 36387   BB bb 36393   BB bb 36468   BB bb 36474   BB bb 36546   CC aa 31953   CC aa 32105   CC aa 32282   CC aa 32554   CC bb 29936   CC bb 30412   DD aa 28745   DD aa 29334   DD aa 29366   DD bb 27306   DD bb 27471   DD bb 27549   DD bb 28027   EE aa 24781   EE aa 25445   EE bb 23900   EE bb 24039   EE bb 24416   FF aa 22349   FF aa 22352   FF aa 22401   FF aa 22811   FF bb 19918   FF bb 19986   FF bb 20130   FF bb 20282   FF bb 20561   FF bb 20754   GG aa 16717   GG aa 16871   GG aa 17016   GG aa 17203   GG bb 14816   GG bb 14825   GG bb 14910   GG bb 15594   HH aa 11904   HH aa 12093   HH aa 12403   HH bb 9671   HH bb 9904   HH bb 9951   HH bb 10279   HH bb 10304   HH bb 10501   II aa 6788   II aa 7042   II bb 5585   II bb 5719   II bb 5947   II bb 5969   II bb 6140   JJ aa 2901   JJ aa 3032   JJ aa 3566   JJ aa 3687   JJ bb 947   JJ bb 1432   JJ bb 1450   JJ bb 1529}

do_execsql_test 1.16.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 4685   AA aa 4685   AA aa 4685   AA aa 4685   AA bb 4685   AA bb 4685   AA bb 4685   AA bb 4685   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB aa 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   BB bb 7340   CC aa 3122   CC aa 3122   CC aa 3122   CC aa 3122   CC bb 3122   CC bb 3122   DD aa 4032   DD aa 4032   DD aa 4032   DD bb 4032   DD bb 4032   DD bb 4032   DD bb 4032   EE aa 2539   EE aa 2539   EE bb 2539   EE bb 2539   EE bb 2539   FF aa 5668   FF aa 5668   FF aa 5668   FF aa 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   FF bb 5668   GG aa 4468   GG aa 4468   GG aa 4468   GG aa 4468   GG bb 4468   GG bb 4468   GG bb 4468   GG bb 4468   HH aa 5443   HH aa 5443   HH aa 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   HH bb 5443   II aa 3640   II aa 3640   II bb 3640   II bb 3640   II bb 3640   II bb 3640   II bb 3640   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ aa 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800   JJ bb 3800}

do_execsql_test 1.16.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 2378   AA bb 2378   AA bb 2378   AA bb 2378   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467   CC aa 1954   CC aa 1954   CC aa 1954   CC aa 1954   CC bb 1168   CC bb 1168   DD aa 1325   DD aa 1325   DD aa 1325   DD bb 2707   DD bb 2707   DD bb 2707   DD bb 2707   EE aa 890   EE aa 890   EE bb 1649   EE bb 1649   EE bb 1649   FF aa 2163   FF aa 2163   FF aa 2163   FF aa 2163   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   GG aa 1597   GG aa 1597   GG aa 1597   GG aa 1597   GG bb 2871   GG bb 2871   GG bb 2871   GG bb 2871   HH aa 2249   HH aa 2249   HH aa 2249   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   II aa 1050   II aa 1050   II bb 2590   II bb 2590   II bb 2590   II bb 2590   II bb 2590   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ bb 1786   JJ bb 1786   JJ bb 1786   JJ bb 1786}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 870   AA bb 870   AA bb 870   AA bb 870   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB aa 762   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840   CC aa 759   CC aa 759   CC aa 759   CC aa 759   CC bb 822   CC bb 822   DD aa 845   DD aa 845   DD aa 845   DD bb 959   DD bb 959   DD bb 959   DD bb 959   EE aa 777   EE aa 777   EE bb 768   EE bb 768   EE bb 768   FF aa 670   FF aa 670   FF aa 670   FF aa 670   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   GG aa 634   GG aa 634   GG aa 634   GG aa 634   GG bb 938   GG bb 938   GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 652   II aa 652   II bb 805   II bb 805   II bb 805   II bb 805   II bb 805   JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839   JJ bb 839   JJ bb 839}

do_execsql_test 1.16.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 223   AA aa 223   AA aa 223   AA aa 223   AA bb 309   AA bb 309   AA bb 309   AA bb 309   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB aa 247   BB bb 633   BB bb 633   BB bb 633   BB bb 633   BB bb 633   BB bb 633   CC aa 158   CC aa 158   CC aa 158   CC aa 158   CC bb 346   CC bb 346   DD aa 224   DD aa 224   DD aa 224   DD bb 238   DD bb 238   DD bb 238   DD bb 238   EE aa 113   EE aa 113   EE bb 252   EE bb 252   EE bb 252   FF aa 208   FF aa 208   FF aa 208   FF aa 208   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   FF bb 102   GG aa 148   GG aa 148   GG aa 148   GG aa 148   GG bb 160   GG bb 160   GG bb 160   GG bb 160   HH aa 480   HH aa 480   HH aa 480   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   HH bb 133   II aa 398   II aa 398   II bb 250   II bb 250   II bb 250   II bb 250   II bb 250   JJ aa 113   JJ aa 113   JJ aa 113   JJ aa 113   JJ bb 257   JJ bb 257   JJ bb 257   JJ bb 257}

do_execsql_test 1.16.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751   AA aa 3774   AA aa 4446   AA aa 4462   AA bb 3815   AA bb 4058   AA bb 4113   AA bb 4376   BB aa 6578   BB aa 6680   BB aa 6928   BB aa 6941   BB aa 6947   BB aa 7093   BB bb 6500   BB bb 6548   BB bb 6554   BB bb 6629   BB bb 6635   BB bb 6707   CC aa 2363   CC aa 2515   CC aa 2692   CC aa 2964   CC bb 2300   CC bb 2776   DD aa 3187   DD aa 3776   DD aa 3808   DD bb 3073   DD bb 3238   DD bb 3316   DD bb 3794   EE aa 1762   EE aa 2426   EE bb 1771   EE bb 1910   EE bb 2287   FF aa 4998   FF aa 5001   FF aa 5050   FF aa 5460   FF bb 4730   FF bb 4798   FF bb 4942   FF bb 5094   FF bb 5373   FF bb 5566   GG aa 3834   GG aa 3988   GG aa 4133   GG aa 4320   GG bb 3530   GG bb 3539   GG bb 3624   GG bb 4308   HH aa 4464   HH aa 4653   HH aa 4963   HH bb 4480   HH bb 4713   HH bb 4760   HH bb 5088   HH bb 5113   HH bb 5310   II aa 2988   II aa 3242   II bb 2835   II bb 2969   II bb 3197   II bb 3219   II bb 3390   JJ aa 2901   JJ aa 3032   JJ aa 3566   JJ aa 3687   JJ bb 2961   JJ bb 3446   JJ bb 3464   JJ bb 3543}

do_execsql_test 1.16.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1373   AA aa 1396   AA aa 2068   AA aa 2084   AA bb 1508   AA bb 1751   AA bb 1806   AA bb 2069   BB aa 2111   BB aa 2213   BB aa 2461   BB aa 2474   BB aa 2480   BB aa 2626   BB bb 3627   BB bb 3675   BB bb 3681   BB bb 3756   BB bb 3762   BB bb 3834   CC aa 1195   CC aa 1347   CC aa 1524   CC aa 1796   CC bb 346   CC bb 822   DD aa 480   DD aa 1069   DD aa 1101   DD bb 1748   DD bb 1913   DD bb 1991   DD bb 2469   EE aa 113   EE aa 777   EE bb 881   EE bb 1020   EE bb 1397   FF aa 1493   FF aa 1496   FF aa 1545   FF aa 1955   FF bb 2567   FF bb 2635   FF bb 2779   FF bb 2931   FF bb 3210   FF bb 3403   GG aa 963   GG aa 1117   GG aa 1262   GG aa 1449   GG bb 1933   GG bb 1942   GG bb 2027   GG bb 2711   HH aa 1270   HH aa 1459   HH aa 1769   HH bb 2231   HH bb 2464   HH bb 2511   HH bb 2839   HH bb 2864   HH bb 3061   II aa 398   II aa 652   II bb 1785   II bb 1919   II bb 2147   II bb 2169   II bb 2340   JJ aa 1115   JJ aa 1246   JJ aa 1780   JJ aa 1901   JJ bb 947   JJ bb 1432   JJ bb 1450   JJ bb 1529}

do_execsql_test 1.17.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.17.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.17.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.17.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.17.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb {}   AA bb {}   AA bb {}   AA bb {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB aa {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   BB bb {}   CC aa {}   CC aa {}   CC aa {}   CC aa {}   CC bb {}   CC bb {}   DD aa {}   DD aa {}   DD aa {}   DD bb {}   DD bb {}   DD bb {}   DD bb {}   EE aa {}   EE aa {}   EE bb {}   EE bb {}   EE bb {}   FF aa {}   FF aa {}   FF aa {}   FF aa {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   FF bb {}   GG aa {}   GG aa {}   GG aa {}   GG aa {}   GG bb {}   GG bb {}   GG bb {}   GG bb {}   HH aa {}   HH aa {}   HH aa {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   HH bb {}   II aa {}   II aa {}   II bb {}   II bb {}   II bb {}   II bb {}   II bb {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.18.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 22701   AA aa 22701   AA aa 22701   AA aa 22701   AA bb 22701   AA bb 22701   AA bb 22701   AA bb 22701   BB aa 19829   BB aa 19829   BB aa 19829   BB aa 19829   BB aa 19829   BB aa 19829   BB bb 19829   BB bb 19829   BB bb 19829   BB bb 19829   BB bb 19829   BB bb 19829   CC aa 22150   CC aa 22150   CC aa 22150   CC aa 22150   CC bb 22150   CC bb 22150   DD aa 21758   DD aa 21758   DD aa 21758   DD bb 21758   DD bb 21758   DD bb 21758   DD bb 21758   EE aa 23019   EE aa 23019   EE bb 23019   EE bb 23019   EE bb 23019   FF aa 17351   FF aa 17351   FF aa 17351   FF aa 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   GG aa 12883   GG aa 12883   GG aa 12883   GG aa 12883   GG bb 12883   GG bb 12883   GG bb 12883   GG bb 12883   HH aa 7440   HH aa 7440   HH aa 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 3800   II aa 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.18.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 12840   AA aa 12840   AA aa 12840   AA aa 12840   AA bb 11787   AA bb 11787   AA bb 11787   AA bb 11787   BB aa 11621   BB aa 11621   BB aa 11621   BB aa 11621   BB aa 11621   BB aa 11621   BB bb 8044   BB bb 8044   BB bb 8044   BB bb 8044   BB bb 8044   BB bb 8044   CC aa 7739   CC aa 7739   CC aa 7739   CC aa 7739   CC bb 8734   CC bb 8734   DD aa 10914   DD aa 10914   DD aa 10914   DD bb 9804   DD bb 9804   DD bb 9804   DD bb 9804   EE aa 11785   EE aa 11785   EE bb 12385   EE bb 12385   EE bb 12385   FF aa 13416   FF aa 13416   FF aa 13416   FF aa 13416   FF bb 10961   FF bb 10961   FF bb 10961   FF bb 10961   FF bb 10961   FF bb 10961   GG aa 11954   GG aa 11954   GG aa 11954   GG aa 11954   GG bb 11097   GG bb 11097   GG bb 11097   GG bb 11097   HH aa 10634   HH aa 10634   HH aa 10634   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 6390   II aa 6390   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 870   AA aa 870   AA aa 870   AA aa 870   AA bb 845   AA bb 845   AA bb 845   AA bb 845   BB aa 959   BB aa 959   BB aa 959   BB aa 959   BB aa 959   BB aa 959   BB bb 959   BB bb 959   BB bb 959   BB bb 959   BB bb 959   BB bb 959   CC aa 959   CC aa 959   CC aa 959   CC aa 959   CC bb 959   CC bb 959   DD aa 959   DD aa 959   DD aa 959   DD bb 938   DD bb 938   DD bb 938   DD bb 938   EE aa 938   EE aa 938   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 963   HH aa 963   HH aa 963   HH bb 899   HH bb 899   HH bb 899   HH bb 899   HH bb 899   HH bb 899   II aa 899   II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 839   JJ aa 839   JJ aa 839   JJ aa 839   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.18.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 158   AA aa 158   AA aa 158   AA aa 158   AA bb 158   AA bb 158   AA bb 158   AA bb 158   BB aa 158   BB aa 158   BB aa 158   BB aa 158   BB aa 158   BB aa 158   BB bb 113   BB bb 113   BB bb 113   BB bb 113   BB bb 113   BB bb 113   CC aa 113   CC aa 113   CC aa 113   CC aa 113   CC bb 113   CC bb 113   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 133   FF bb 133   FF bb 133   FF bb 133   FF bb 133   FF bb 133   GG aa 133   GG aa 133   GG aa 133   GG aa 133   GG bb 113   GG bb 113   GG bb 113   GG bb 113   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 257   JJ aa 257   JJ aa 257   JJ aa 257   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.18.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 22701   AA aa 22701   AA aa 22701   AA aa 22701   AA bb 22701   AA bb 22701   AA bb 22701   AA bb 22701   BB aa 19829   BB aa 19829   BB aa 19829   BB aa 19829   BB aa 19829   BB aa 19829   BB bb 19829   BB bb 19829   BB bb 19829   BB bb 19829   BB bb 19829   BB bb 19829   CC aa 22150   CC aa 22150   CC aa 22150   CC aa 22150   CC bb 22150   CC bb 22150   DD aa 21758   DD aa 21758   DD aa 21758   DD bb 21758   DD bb 21758   DD bb 21758   DD bb 21758   EE aa 23019   EE aa 23019   EE bb 23019   EE bb 23019   EE bb 23019   FF aa 17351   FF aa 17351   FF aa 17351   FF aa 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   GG aa 12883   GG aa 12883   GG aa 12883   GG aa 12883   GG bb 12883   GG bb 12883   GG bb 12883   GG bb 12883   HH aa 7440   HH aa 7440   HH aa 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 3800   II aa 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.18.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 12840   AA aa 12840   AA aa 12840   AA aa 12840   AA bb 11787   AA bb 11787   AA bb 11787   AA bb 11787   BB aa 11621   BB aa 11621   BB aa 11621   BB aa 11621   BB aa 11621   BB aa 11621   BB bb 8044   BB bb 8044   BB bb 8044   BB bb 8044   BB bb 8044   BB bb 8044   CC aa 7739   CC aa 7739   CC aa 7739   CC aa 7739   CC bb 8734   CC bb 8734   DD aa 10914   DD aa 10914   DD aa 10914   DD bb 9804   DD bb 9804   DD bb 9804   DD bb 9804   EE aa 11785   EE aa 11785   EE bb 12385   EE bb 12385   EE bb 12385   FF aa 13416   FF aa 13416   FF aa 13416   FF aa 13416   FF bb 10961   FF bb 10961   FF bb 10961   FF bb 10961   FF bb 10961   FF bb 10961   GG aa 11954   GG aa 11954   GG aa 11954   GG aa 11954   GG bb 11097   GG bb 11097   GG bb 11097   GG bb 11097   HH aa 10634   HH aa 10634   HH aa 10634   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 6390   II aa 6390   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.19.1 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 40052   AA aa 40052   AA aa 40052   AA aa 40052   AA bb 40052   AA bb 40052   AA bb 40052   AA bb 40052   BB aa 32712   BB aa 32712   BB aa 32712   BB aa 32712   BB aa 32712   BB aa 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   CC aa 29590   CC aa 29590   CC aa 29590   CC aa 29590   CC bb 29590   CC bb 29590   DD aa 25558   DD aa 25558   DD aa 25558   DD bb 25558   DD bb 25558   DD bb 25558   DD bb 25558   EE aa 23019   EE aa 23019   EE bb 23019   EE bb 23019   EE bb 23019   FF aa 17351   FF aa 17351   FF aa 17351   FF aa 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   GG aa 12883   GG aa 12883   GG aa 12883   GG aa 12883   GG bb 12883   GG bb 12883   GG bb 12883   GG bb 12883   HH aa 7440   HH aa 7440   HH aa 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 3800   II aa 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.19.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 42430   AA aa 42430   AA aa 42430   AA aa 42430   AA bb 40052   AA bb 40052   AA bb 40052   AA bb 40052   BB aa 37179   BB aa 37179   BB aa 37179   BB aa 37179   BB aa 37179   BB aa 37179   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   CC aa 30758   CC aa 30758   CC aa 30758   CC aa 30758   CC bb 29590   CC bb 29590   DD aa 28265   DD aa 28265   DD aa 28265   DD bb 25558   DD bb 25558   DD bb 25558   DD bb 25558   EE aa 24668   EE aa 24668   EE bb 23019   EE bb 23019   EE bb 23019   FF aa 20856   FF aa 20856   FF aa 20856   FF aa 20856   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   GG aa 15754   GG aa 15754   GG aa 15754   GG aa 15754   GG bb 12883   GG bb 12883   GG bb 12883   GG bb 12883   HH aa 10634   HH aa 10634   HH aa 10634   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 6390   II aa 6390   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}
................................................................................
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979   AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979   CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979   DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979   EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979   GG bb 979   GG bb 979   HH aa 963   HH aa 963   HH aa 963   HH bb 899   HH bb 899   HH bb 899   HH bb 899   HH bb 899   HH bb 899   II aa 899   II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899   JJ aa 839   JJ aa 839   JJ aa 839   JJ aa 839   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.19.5 {
  SELECT a, b, min(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 102   AA aa 102   AA aa 102   AA aa 102   AA bb 102   AA bb 102   AA bb 102   AA bb 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB aa 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   BB bb 102   CC aa 102   CC aa 102   CC aa 102   CC aa 102   CC bb 102   CC bb 102   DD aa 102   DD aa 102   DD aa 102   DD bb 102   DD bb 102   DD bb 102   DD bb 102   EE aa 102   EE aa 102   EE bb 102   EE bb 102   EE bb 102   FF aa 102   FF aa 102   FF aa 102   FF aa 102   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   FF bb 113   GG aa 113   GG aa 113   GG aa 113   GG aa 113   GG bb 113   GG bb 113   GG bb 113   GG bb 113   HH aa 113   HH aa 113   HH aa 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   HH bb 113   II aa 113   II aa 113   II bb 113   II bb 113   II bb 113   II bb 113   II bb 113   JJ aa 257   JJ aa 257   JJ aa 257   JJ aa 257   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.19.6 {
  SELECT a, b, sum(c) OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 40052   AA aa 40052   AA aa 40052   AA aa 40052   AA bb 40052   AA bb 40052   AA bb 40052   AA bb 40052   BB aa 32712   BB aa 32712   BB aa 32712   BB aa 32712   BB aa 32712   BB aa 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   CC aa 29590   CC aa 29590   CC aa 29590   CC aa 29590   CC bb 29590   CC bb 29590   DD aa 25558   DD aa 25558   DD aa 25558   DD bb 25558   DD bb 25558   DD bb 25558   DD bb 25558   EE aa 23019   EE aa 23019   EE bb 23019   EE bb 23019   EE bb 23019   FF aa 17351   FF aa 17351   FF aa 17351   FF aa 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   GG aa 12883   GG aa 12883   GG aa 12883   GG aa 12883   GG bb 12883   GG bb 12883   GG bb 12883   GG bb 12883   HH aa 7440   HH aa 7440   HH aa 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 3800   II aa 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa {}   JJ aa {}   JJ aa {}   JJ aa {}   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 1.19.7 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 42430   AA aa 42430   AA aa 42430   AA aa 42430   AA bb 40052   AA bb 40052   AA bb 40052   AA bb 40052   BB aa 37179   BB aa 37179   BB aa 37179   BB aa 37179   BB aa 37179   BB aa 37179   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   BB bb 32712   CC aa 30758   CC aa 30758   CC aa 30758   CC aa 30758   CC bb 29590   CC bb 29590   DD aa 28265   DD aa 28265   DD aa 28265   DD bb 25558   DD bb 25558   DD bb 25558   DD bb 25558   EE aa 24668   EE aa 24668   EE bb 23019   EE bb 23019   EE bb 23019   FF aa 20856   FF aa 20856   FF aa 20856   FF aa 20856   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   FF bb 17351   GG aa 15754   GG aa 15754   GG aa 15754   GG aa 15754   GG bb 12883   GG bb 12883   GG bb 12883   GG bb 12883   HH aa 10634   HH aa 10634   HH aa 10634   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   HH bb 7440   II aa 6390   II aa 6390   II bb 3800   II bb 3800   II bb 3800   II bb 3800   II bb 3800   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ aa 1786   JJ bb {}   JJ bb {}   JJ bb {}   JJ bb {}}

do_execsql_test 2.1.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE NO OTHERS 
    )
} {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   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80}

do_execsql_test 2.1.2 {
  SELECT nth_value(c, 14) OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE NO OTHERS 

    )
} {247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247}

do_execsql_test 2.2.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW 
    )
} {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   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80}

do_execsql_test 2.2.2 {
  SELECT nth_value(c, 14) OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW 

    )
} {250   250   250   250   250   250   250   250   250   250   250   250   250   250   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247}

do_execsql_test 2.3.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE GROUP 
    )
} {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   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80}

do_execsql_test 2.3.2 {
  SELECT nth_value(c, 14) OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE GROUP 

    )
} {250   250   250   250   250   250   250   250   250   250   250   250   250   250   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247}

do_execsql_test 2.4.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE TIES 
    )
} {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   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80}

do_execsql_test 2.4.2 {
  SELECT nth_value(c, 14) OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE TIES 

    )
} {247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247   247}

#==========================================================================

do_execsql_test 3.0 {
  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(a REAL, b INTEGER);
  INSERT INTO t1 VALUES