/ Check-in [91c1cb7a]
Login

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

Overview
Comment:Add support for window functions row_number(), rank(), dense_rank() and percent_rank().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | exp-window-functions
Files: files | file ages | folders
SHA3-256:91c1cb7a217d0991a08256269f6c55ef185c25362d57b36bfbd2d85dab38e58f
User & Date: dan 2018-06-02 21:04:28
Context
2018-06-04
08:22
Add support for window function cume_dist(). Improve tests for percent_rank(). check-in: 76543f7d user: dan tags: exp-window-functions
2018-06-02
21:04
Add support for window functions row_number(), rank(), dense_rank() and percent_rank(). check-in: 91c1cb7a user: dan tags: exp-window-functions
2018-06-01
21:00
Allow an entire partition to be cached in a temp table for all types of window frames. This is required by nth_value() and others. check-in: b5b18f66 user: dan tags: exp-window-functions
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/func.c.

1919
1920
1921
1922
1923
1924
1925

1926
1927
1928
1929
1930
1931
1932
    FUNCTION(coalesce,           1, 0, 0, 0                ),
    FUNCTION(coalesce,           0, 0, 0, 0                ),
    FUNCTION2(coalesce,         -1, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),
  };
#ifndef SQLITE_OMIT_ALTERTABLE
  sqlite3AlterFunctions();
#endif

#if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)
  sqlite3AnalyzeFunctions();
#endif
  sqlite3RegisterDateTimeFunctions();
  sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));

#if 0  /* Enable to print out how the built-in functions are hashed */







>







1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
    FUNCTION(coalesce,           1, 0, 0, 0                ),
    FUNCTION(coalesce,           0, 0, 0, 0                ),
    FUNCTION2(coalesce,         -1, 0, 0, noopFunc,  SQLITE_FUNC_COALESCE),
  };
#ifndef SQLITE_OMIT_ALTERTABLE
  sqlite3AlterFunctions();
#endif
  sqlite3WindowFunctions();
#if defined(SQLITE_ENABLE_STAT3) || defined(SQLITE_ENABLE_STAT4)
  sqlite3AnalyzeFunctions();
#endif
  sqlite3RegisterDateTimeFunctions();
  sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));

#if 0  /* Enable to print out how the built-in functions are hashed */

Changes to src/resolve.c.

772
773
774
775
776
777
778

779
780
781
782
783
784
785
             nId, zId);
        pNC->nErr++;
      }
      if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;
      sqlite3WalkExprList(pWalker, pList);
      if( is_agg ){
        if( pExpr->pWin ){

          if( 0==pNC->pWin 
           || 0==sqlite3WindowCompare(pParse, pNC->pWin, pExpr->pWin) 
          ){
            pExpr->pWin->pNextWin = pNC->pWin;
            pNC->pWin = pExpr->pWin;
          }
          pExpr->pWin->pFunc = pDef;







>







772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
             nId, zId);
        pNC->nErr++;
      }
      if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg;
      sqlite3WalkExprList(pWalker, pList);
      if( is_agg ){
        if( pExpr->pWin ){
          sqlite3WindowUpdate(pParse, pExpr->pWin, pDef);
          if( 0==pNC->pWin 
           || 0==sqlite3WindowCompare(pParse, pNC->pWin, pExpr->pWin) 
          ){
            pExpr->pWin->pNextWin = pNC->pWin;
            pNC->pWin = pExpr->pWin;
          }
          pExpr->pWin->pFunc = pDef;

Changes to src/select.c.

4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
....
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
....
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
....
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671






5672
5673
5674
5675
5676
5677
5678
    }
  }
}
#else
#define selectPopWith 0
#endif

static int selectExpandSubquery(Parse *pParse, struct SrcList_item *pFrom){
  Select *pSel = pFrom->pSelect;
  Table *pTab;

  pFrom->pTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table));
  if( pTab==0 ) return WRC_Abort;
  pTab->nTabRef = 1;
  if( pFrom->zAlias ){
................................................................................
    if( pFrom->zName==0 ){
#ifndef SQLITE_OMIT_SUBQUERY
      Select *pSel = pFrom->pSelect;
      /* A sub-query in the FROM clause of a SELECT */
      assert( pSel!=0 );
      assert( pFrom->pTab==0 );
      if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;
      if( selectExpandSubquery(pParse, pFrom) ) return WRC_Abort;
#endif
    }else{
      /* An ordinary table or view name in the FROM clause */
      assert( pFrom->pTab==0 );
      pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom);
      if( pTab==0 ) return WRC_Abort;
      if( pTab->nTabRef>=0xffff ){
................................................................................
    sqlite3TreeViewSelect(0, p, 0);
  }
#endif
  return 1;
}
#endif /* SQLITE_COUNTOFVIEW_OPTIMIZATION */

typedef struct WindowRewrite WindowRewrite;
struct WindowRewrite {
  Window *pWin;
  ExprList *pSub;
};

static int selectWindowRewriteSelectCb(Walker *pWalker, Select *pSelect){
  return WRC_Prune;
}

static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){
  struct WindowRewrite *p = pWalker->u.pRewrite;
  Parse *pParse = pWalker->pParse;

  switch( pExpr->op ){

    case TK_FUNCTION:
      if( pExpr->pWin==0 ){
        break;
      }else{
        Window *pWin;
        for(pWin=p->pWin; pWin; pWin=pWin->pNextWin){
          if( pExpr->pWin==pWin ){
            pExpr->pWin->pOwner = pExpr;
            return WRC_Prune;
          }
        }
      }
      /* Fall through.  */

    case TK_COLUMN: {
      Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);
      p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);
      if( p->pSub ){
        assert( ExprHasProperty(pExpr, EP_Static)==0 );
        ExprSetProperty(pExpr, EP_Static);
        sqlite3ExprDelete(pParse->db, pExpr);
        ExprClearProperty(pExpr, EP_Static);
        memset(pExpr, 0, sizeof(Expr));

        pExpr->op = TK_COLUMN;
        pExpr->iColumn = p->pSub->nExpr-1;
        pExpr->iTable = p->pWin->iEphCsr;
      }

      break;
    }

    default: /* no-op */
      break;
  }

  return WRC_Continue;
}

static int selectWindowRewriteEList(
  Parse *pParse, 
  Window *pWin,
  ExprList *pEList,               /* Rewrite expressions in this list */
  ExprList **ppSub                /* IN/OUT: Sub-select expression-list */
){
  Walker sWalker;
  WindowRewrite sRewrite;
  int rc;

  memset(&sWalker, 0, sizeof(Walker));
  memset(&sRewrite, 0, sizeof(WindowRewrite));

  sRewrite.pSub = *ppSub;
  sRewrite.pWin = pWin;

  sWalker.pParse = pParse;
  sWalker.xExprCallback = selectWindowRewriteExprCb;
  sWalker.xSelectCallback = selectWindowRewriteSelectCb;
  sWalker.u.pRewrite = &sRewrite;

  rc = sqlite3WalkExprList(&sWalker, pEList);

  *ppSub = sRewrite.pSub;
  return rc;
}

static ExprList *exprListAppendList(
  Parse *pParse,          /* Parsing context */
  ExprList *pList,        /* List to which to append. Might be NULL */
  ExprList *pAppend       /* List of values to append. Might be NULL */
){
  if( pAppend ){
    int i;
    int nInit = pList ? pList->nExpr : 0;
    for(i=0; i<pAppend->nExpr; i++){
      Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
      pList = sqlite3ExprListAppend(pParse, pList, pDup);
      if( pList ) pList->a[nInit+i].sortOrder = pAppend->a[i].sortOrder;
    }
  }
  return pList;
}

/*
** If the SELECT statement passed as the second argument does not invoke
** any SQL window functions, this function is a no-op. Otherwise, it 
** rewrites the SELECT statement so that window function xStep functions
** are invoked in the correct order. The simplest version of the 
** transformation is:
**
**   SELECT win(args...) OVER (<list1>) FROM <src> ORDER BY <list2>
**
** to
**
**   SELECT win(args...) FROM (
**     SELECT args... FROM <src> ORDER BY <list1>
**   ) ORDER BY <list2>
**
** where <src> may contain WHERE, GROUP BY and HAVING clauses, and <list1>
** is the concatenation of the PARTITION BY and ORDER BY clauses in the
** OVER clause.
**
*/
static int selectWindowRewrite(Parse *pParse, Select *p){
  int rc = SQLITE_OK;
  if( p->pWin ){
    Vdbe *v = sqlite3GetVdbe(pParse);
    int i;
    sqlite3 *db = pParse->db;
    Select *pSub = 0;             /* The subquery */
    SrcList *pSrc = p->pSrc;
    Expr *pWhere = p->pWhere;
    ExprList *pGroupBy = p->pGroupBy;
    Expr *pHaving = p->pHaving;
    ExprList *pSort = 0;

    ExprList *pSublist = 0;       /* Expression list for sub-query */
    Window *pMWin = p->pWin;      /* Master window object */
    Window *pWin;                 /* Window object iterator */

    p->pSrc = 0;
    p->pWhere = 0;
    p->pGroupBy = 0;
    p->pHaving = 0;

    /* Assign a cursor number for the ephemeral table used to buffer rows.
    ** The OpenEphemeral instruction is coded later, after it is known how
    ** many columns the table will have.  */
    pMWin->iEphCsr = pParse->nTab++;

    rc = selectWindowRewriteEList(pParse, pMWin, p->pEList, &pSublist);
    if( rc ) return rc;
    rc = selectWindowRewriteEList(pParse, pMWin, p->pOrderBy, &pSublist);
    if( rc ) return rc;
    pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0);

    /* Create the ORDER BY clause for the sub-select. This is the concatenation
    ** of the window PARTITION and ORDER BY clauses. Append the same 
    ** expressions to the sub-select expression list. They are required to
    ** figure out where boundaries for partitions and sets of peer rows.  */
    pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
    if( pMWin->pOrderBy ){
      pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy);
    }
    pSublist = exprListAppendList(pParse, pSublist, pSort);

    /* Append the arguments passed to each window function to the
    ** sub-select expression list. Also allocate two registers for each
    ** window function - one for the accumulator, another for interim
    ** results.  */
    for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
      pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
      pSublist = exprListAppendList(pParse, pSublist, pWin->pOwner->x.pList);
      pWin->regAccum = ++pParse->nMem;
      pWin->regResult = ++pParse->nMem;
      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
    }

    pSub = sqlite3SelectNew(
        pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
    );
    p->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
    if( p->pSrc ){
      int iTab;
      ExprList *pList = 0;
      p->pSrc->a[0].pSelect = pSub;
      sqlite3SrcListAssignCursors(pParse, p->pSrc);
      if( selectExpandSubquery(pParse, &p->pSrc->a[0]) ){
        rc = SQLITE_NOMEM;
      }else{
        pSub->selFlags |= SF_Expanded;
      }
    }

#if SELECTTRACE_ENABLED
    if( sqlite3SelectTrace & 0x108 ){
      SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
      sqlite3TreeViewSelect(0, p, 0);
    }
#endif

    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr);
  }

  return rc;
}

/*
** Generate code for the SELECT statement given in the p argument.  
**
** The results are returned according to the SelectDest structure.
** See comments in sqliteInt.h for further information.
**
** This routine returns the number of errors.  If any errors are
................................................................................
  }
#endif

  if( pDest->eDest==SRT_Output ){
    generateColumnNames(pParse, p);
  }

  if( (rc = selectWindowRewrite(pParse, p)) ){
    goto select_end;
  }






  pTabList = p->pSrc;

  /* Try to various optimizations (flattening subqueries, and strength
  ** reduction of join operators) in the FROM clause up into the main query
  */
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
  for(i=0; !p->pPrior && i<pTabList->nSrc; i++){







|







 







|







 







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







 







|


>
>
>
>
>
>







4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
....
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
....
5375
5376
5377
5378
5379
5380
5381











































































































































































































5382
5383
5384
5385
5386
5387
5388
....
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
    }
  }
}
#else
#define selectPopWith 0
#endif

int sqlite3ExpandSubquery(Parse *pParse, struct SrcList_item *pFrom){
  Select *pSel = pFrom->pSelect;
  Table *pTab;

  pFrom->pTab = pTab = sqlite3DbMallocZero(pParse->db, sizeof(Table));
  if( pTab==0 ) return WRC_Abort;
  pTab->nTabRef = 1;
  if( pFrom->zAlias ){
................................................................................
    if( pFrom->zName==0 ){
#ifndef SQLITE_OMIT_SUBQUERY
      Select *pSel = pFrom->pSelect;
      /* A sub-query in the FROM clause of a SELECT */
      assert( pSel!=0 );
      assert( pFrom->pTab==0 );
      if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;
      if( sqlite3ExpandSubquery(pParse, pFrom) ) return WRC_Abort;
#endif
    }else{
      /* An ordinary table or view name in the FROM clause */
      assert( pFrom->pTab==0 );
      pFrom->pTab = pTab = sqlite3LocateTableItem(pParse, 0, pFrom);
      if( pTab==0 ) return WRC_Abort;
      if( pTab->nTabRef>=0xffff ){
................................................................................
    sqlite3TreeViewSelect(0, p, 0);
  }
#endif
  return 1;
}
#endif /* SQLITE_COUNTOFVIEW_OPTIMIZATION */












































































































































































































/*
** Generate code for the SELECT statement given in the p argument.  
**
** The results are returned according to the SelectDest structure.
** See comments in sqliteInt.h for further information.
**
** This routine returns the number of errors.  If any errors are
................................................................................
  }
#endif

  if( pDest->eDest==SRT_Output ){
    generateColumnNames(pParse, p);
  }

  if( (rc = sqlite3WindowRewrite(pParse, p)) ){
    goto select_end;
  }
#if SELECTTRACE_ENABLED
  if( sqlite3SelectTrace & 0x108 ){
    SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n"));
    sqlite3TreeViewSelect(0, p, 0);
  }
#endif
  pTabList = p->pSrc;

  /* Try to various optimizations (flattening subqueries, and strength
  ** reduction of join operators) in the FROM clause up into the main query
  */
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
  for(i=0; !p->pPrior && i<pTabList->nSrc; i++){

Changes to src/sqliteInt.h.

1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
....
1643
1644
1645
1646
1647
1648
1649


1650
1651
1652
1653
1654
1655
1656
....
3497
3498
3499
3500
3501
3502
3503



3504
3505
3506
3507
3508
3509
3510
....
4171
4172
4173
4174
4175
4176
4177

4178
4179
4180
4181
4182
4183
4184
** structure is held in the db->aHash hash table.
**
** The u.pHash field is used by the global built-ins.  The u.pDestructor
** field is used by per-connection app-def functions.
*/
struct FuncDef {
  i8 nArg;             /* Number of arguments.  -1 means unlimited */
  u16 funcFlags;       /* Some combination of SQLITE_FUNC_* */
  void *pUserData;     /* User data parameter */
  FuncDef *pNext;      /* Next function with same name */
  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
  void (*xFinalize)(sqlite3_context*);                  /* Agg finalizer */
  void (*xValue)(sqlite3_context*);                     /* Current agg value */
  void (*xInverse)(sqlite3_context*,int,sqlite3_value**); /* inverse agg-step */
  const char *zName;   /* SQL name of the function. */
................................................................................
#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
#define SQLITE_FUNC_MINMAX   0x1000 /* True for min() and max() aggregates */
#define SQLITE_FUNC_SLOCHNG  0x2000 /* "Slow Change". Value constant during a
                                    ** single query - might change over time */
#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
#define SQLITE_FUNC_OFFSET   0x8000 /* Built-in sqlite_offset() function */



/*
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
** used to create the initializers for the FuncDef structures.
**
**   FUNCTION(zName, nArg, iArg, bNC, xFunc)
**     Used to create a scalar function definition of a function zName
................................................................................

void sqlite3WindowDelete(sqlite3*, Window*);
Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*);
void sqlite3WindowAttach(Parse*, Expr*, Window*);
int sqlite3WindowCompare(Parse*, Window*, Window*);
void sqlite3WindowCodeInit(Parse*, Window*);
void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int, int*);




/*
** Assuming zIn points to the first byte of a UTF-8 character,
** advance zIn to point to the first byte of the next UTF-8 character.
*/
#define SQLITE_SKIP_UTF8(zIn) {                        \
  if( (*(zIn++))>=0xc0 ){                              \
................................................................................
#endif
#ifdef VDBE_PROFILE
extern sqlite3_uint64 sqlite3NProfileCnt;
#endif
void sqlite3RootPageMoved(sqlite3*, int, int, int);
void sqlite3Reindex(Parse*, Token*, Token*);
void sqlite3AlterFunctions(void);

void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
int sqlite3GetToken(const unsigned char *, int *);
void sqlite3NestedParse(Parse*, const char*, ...);
void sqlite3ExpirePreparedStatements(sqlite3*);
int sqlite3CodeSubselect(Parse*, Expr *, int, int);
void sqlite3SelectPrep(Parse*, Select*, NameContext*);
void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);







|







 







>
>







 







>
>
>







 







>







1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
....
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
....
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
....
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
** structure is held in the db->aHash hash table.
**
** The u.pHash field is used by the global built-ins.  The u.pDestructor
** field is used by per-connection app-def functions.
*/
struct FuncDef {
  i8 nArg;             /* Number of arguments.  -1 means unlimited */
  u32 funcFlags;       /* Some combination of SQLITE_FUNC_* */
  void *pUserData;     /* User data parameter */
  FuncDef *pNext;      /* Next function with same name */
  void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
  void (*xFinalize)(sqlite3_context*);                  /* Agg finalizer */
  void (*xValue)(sqlite3_context*);                     /* Current agg value */
  void (*xInverse)(sqlite3_context*,int,sqlite3_value**); /* inverse agg-step */
  const char *zName;   /* SQL name of the function. */
................................................................................
#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
#define SQLITE_FUNC_MINMAX   0x1000 /* True for min() and max() aggregates */
#define SQLITE_FUNC_SLOCHNG  0x2000 /* "Slow Change". Value constant during a
                                    ** single query - might change over time */
#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
#define SQLITE_FUNC_OFFSET   0x8000 /* Built-in sqlite_offset() function */
#define SQLITE_FUNC_WINDOW  0x10000 /* Built-in window-only function */
#define SQLITE_FUNC_WINDOW_SIZE  0x20000

/*
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
** used to create the initializers for the FuncDef structures.
**
**   FUNCTION(zName, nArg, iArg, bNC, xFunc)
**     Used to create a scalar function definition of a function zName
................................................................................

void sqlite3WindowDelete(sqlite3*, Window*);
Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*);
void sqlite3WindowAttach(Parse*, Expr*, Window*);
int sqlite3WindowCompare(Parse*, Window*, Window*);
void sqlite3WindowCodeInit(Parse*, Window*);
void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int, int*);
int sqlite3WindowRewrite(Parse*, Select*);
int sqlite3ExpandSubquery(Parse*, struct SrcList_item*);
void sqlite3WindowUpdate(Parse*, Window*, FuncDef*);

/*
** Assuming zIn points to the first byte of a UTF-8 character,
** advance zIn to point to the first byte of the next UTF-8 character.
*/
#define SQLITE_SKIP_UTF8(zIn) {                        \
  if( (*(zIn++))>=0xc0 ){                              \
................................................................................
#endif
#ifdef VDBE_PROFILE
extern sqlite3_uint64 sqlite3NProfileCnt;
#endif
void sqlite3RootPageMoved(sqlite3*, int, int, int);
void sqlite3Reindex(Parse*, Token*, Token*);
void sqlite3AlterFunctions(void);
void sqlite3WindowFunctions(void);
void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
int sqlite3GetToken(const unsigned char *, int *);
void sqlite3NestedParse(Parse*, const char*, ...);
void sqlite3ExpirePreparedStatements(sqlite3*);
int sqlite3CodeSubselect(Parse*, Expr *, int, int);
void sqlite3SelectPrep(Parse*, Select*, NameContext*);
void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);

Changes to src/window.c.

6
7
8
9
10
11
12










































































































































































































































































































































































































13
14
15
16
17
18
19
...
121
122
123
124
125
126
127
128

129
130
131
132

133





134
135
136
137
138
139
140
141
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
...
194
195
196
197
198
199
200
201

202
203
204
205
206
207
208
209
210
211
212
213

214
215
216
217
218
219
220
...
401
402
403
404
405
406
407

408
409
410
411
412
413
414
...
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
...
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
...
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
...
630
631
632
633
634
635
636

637
638
639
640
641
642
643
...
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
...
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
...
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
...
915
916
917
918
919
920
921

922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941

942
943
944
945
946
947
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
*/
#include "sqliteInt.h"











































































































































































































































































































































































































void sqlite3WindowDelete(sqlite3 *db, Window *p){
  if( p ){
    sqlite3ExprDelete(db, p->pFilter);
    sqlite3ExprListDelete(db, p->pPartition);
    sqlite3ExprListDelete(db, p->pOrderBy);
    sqlite3ExprDelete(db, p->pEnd);
................................................................................
** linked list starting at pMWin.
*/
static void windowAggStep(
  Parse *pParse, 
  Window *pMWin, 
  int csr,
  int bInverse, 
  int reg

){
  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;
  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){

    int regArg;





    if( csr>=0 ){
      int i;
      for(i=0; i<pWin->nArg; i++){
        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
      }
      regArg = reg;
    }else{
      regArg = reg + pWin->iArgCol;
................................................................................
      if( pWin->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
        CollSeq *pColl;
        pColl = sqlite3ExprCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);
        sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
      }
      sqlite3VdbeAddOp3(v, OP_AggStep0, bInverse, regArg, pWin->regAccum);
      sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
      sqlite3VdbeChangeP5(v, (u8)pWin->nArg);
    }
  }
}

static void windowAggFinal(Parse *pParse, Window *pMWin, int bFinal){
  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;
................................................................................
}

static void windowPartitionCache(
  Parse *pParse,
  Select *p,
  WhereInfo *pWInfo,
  int regFlushPart,
  int lblFlushPart

){
  Window *pMWin = p->pWin;
  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;
  int iSubCsr = p->pSrc->a[0].iCursor;
  int nSub = p->pSrc->a[0].pTab->nCol;
  int k;

  int reg = pParse->nMem+1;
  int regRecord = reg+nSub;
  int regRowid = regRecord+1;


  pParse->nMem += nSub + 2;

  /* Martial the row returned by the sub-select into an array of 
  ** registers. */
  for(k=0; k<nSub; k++){
    sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
  }
................................................................................
  int addrIfPos2;

  int regPeer = 0;                 /* Number of peers in current group */
  int regPeerVal = 0;              /* Array of values identifying peer group */
  int iPeer = 0;                   /* Column offset in eph-table of peer vals */
  int nPeerVal;                    /* Number of peer values */
  int bRange = 0;


  assert( pMWin->eStart==TK_PRECEDING 
       || pMWin->eStart==TK_CURRENT 
       || pMWin->eStart==TK_FOLLOWING 
       || pMWin->eStart==TK_UNBOUNDED 
  );
  assert( pMWin->eEnd==TK_FOLLOWING 
................................................................................
  regFlushPart = ++pParse->nMem;
  lblFlushPart = sqlite3VdbeMakeLabel(v);
  lblFlushDone = sqlite3VdbeMakeLabel(v);

  regStart = ++pParse->nMem;
  regEnd = ++pParse->nMem;

  windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart);

  addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);

  /* Start of "flush_partition" */
  sqlite3VdbeResolveLabel(v, lblFlushPart);
  sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);
  sqlite3VdbeAddOp2(v, OP_OpenDup, csrStart, pMWin->iEphCsr);
................................................................................
  ** do nothing.  */
  addrTop = sqlite3VdbeCurrentAddr(v);
  if( pMWin->eEnd==TK_PRECEDING ){
    addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
  }
  sqlite3VdbeAddOp2(v, OP_Next, csrEnd, sqlite3VdbeCurrentAddr(v)+2);
  addr = sqlite3VdbeAddOp0(v, OP_Goto);
  windowAggStep(pParse, pMWin, csrEnd, 0, regArg);
  if( pMWin->eEnd==TK_UNBOUNDED ){
    sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
    sqlite3VdbeJumpHere(v, addr);
    addrTop = sqlite3VdbeCurrentAddr(v);
  }else{
    sqlite3VdbeJumpHere(v, addr);
    if( pMWin->eEnd==TK_PRECEDING ){
................................................................................
      addrJumpHere = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
    }
    if( bRange ){
      sqlite3VdbeAddOp3(v, OP_IfPos, regPeer, sqlite3VdbeCurrentAddr(v)+2, 1);
      addrJumpHere = sqlite3VdbeAddOp0(v, OP_Goto);
    }
    sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
    windowAggStep(pParse, pMWin, csrStart, 1, regArg);
    if( bRange ){
      sqlite3VdbeAddOp2(v, OP_Goto, 0, addrJumpHere-1);
    }
    if( addrJumpHere ){
      sqlite3VdbeJumpHere(v, addrJumpHere);
    }
  }
................................................................................
  int addrGoto;                   /* Address of Goto used to jump flush_par.. */
  int addrRewind;                 /* Address of Rewind that starts loop */
  int regFlushPart;
  int lblFlushPart;
  int csrLead;
  int regCtr;
  int regArg;                     /* Register array to martial function args */

  int nArg;

  assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT) 
  );

  regNewPeer = pParse->nMem+1;
  pParse->nMem += nPeer;
................................................................................
  /* Allocate register and label for the "flush_partition" sub-routine. */
  regFlushPart = ++pParse->nMem;
  lblFlushPart = sqlite3VdbeMakeLabel(v);

  csrLead = pParse->nTab++;
  regCtr = ++pParse->nMem;

  windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart);
  addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);

  /* Start of "flush_partition" */
  sqlite3VdbeResolveLabel(v, lblFlushPart);
  sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+2);
  sqlite3VdbeAddOp2(v, OP_OpenDup, csrLead, pMWin->iEphCsr);

................................................................................
    sqlite3VdbeAddOp3(v, OP_IfPos, regCtr, sqlite3VdbeCurrentAddr(v)+2 , 1);
    sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+3);
    sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
    sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-3);
    sqlite3VdbeJumpHere(v, addrJump);
  }

  windowAggStep(pParse, pMWin, csrLead, 0, regArg);
  sqlite3VdbeAddOp2(v, OP_AddImm, regCtr, 1);

  sqlite3VdbeAddOp2(v, OP_Next, csrLead, addrRewind+2);

  windowAggFinal(pParse, pMWin, 1);

  sqlite3VdbeAddOp3(v, OP_IfPos, regCtr, sqlite3VdbeCurrentAddr(v)+2 , 1);
................................................................................
        v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
    );

    if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
  }

  /* Invoke step function for window functions */
  windowAggStep(pParse, pMWin, -1, 0, reg);

  /* Buffer the current row in the ephemeral table. */
  if( pMWin->nBufferCol>0 ){
    sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, pMWin->nBufferCol, regRecord);
  }else{
    sqlite3VdbeAddOp2(v, OP_Blob, 0, regRecord);
    sqlite3VdbeAppendP4(v, (void*)"", 0);
................................................................................
  Select *p,
  WhereInfo *pWInfo,
  int regGosub, 
  int addrGosub,
  int *pbLoop
){
  Window *pMWin = p->pWin;


  *pbLoop = 0;
  if( (pMWin->eType==TK_ROWS 
   && (pMWin->eStart!=TK_UNBOUNDED||pMWin->eEnd!=TK_CURRENT||!pMWin->pOrderBy))
   || (pMWin->eStart==TK_CURRENT&&pMWin->eEnd==TK_UNBOUNDED&&pMWin->pOrderBy)
  ){
    windowCodeRowExprStep(pParse, p, pWInfo, regGosub, addrGosub);
    return;
  }

#if 0
  if( pMWin->eType==TK_RANGE
   && pMWin->eStart==TK_UNBOUNDED
   && pMWin->eEnd==TK_CURRENT
   && pMWin->pOrderBy
  ){
    windowCodeCacheStep(pParse, p, pWInfo, regGosub, addrGosub);
    return;
  }
#endif


  *pbLoop = 1;
  windowCodeDefaultStep(pParse, p, pWInfo, regGosub, addrGosub);
}









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







 







|
>




>

>
>
>
>
>
|







 







|







 







|
>












>







 







>







 







|







 







|







 







|







 







>







 







|







 







|







 







|







 







>










|
|
<
<
<
<
|
|
|
<
>






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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
...
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
...
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
...
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
...
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
...
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
...
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
...
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
....
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
....
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
....
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
....
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
....
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339




1340
1341
1342

1343
1344
1345
1346
1347
1348
1349
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
*/
#include "sqliteInt.h"

/*
** Implementation of built-in window function row_number(). Assumes that the
** window frame has been coerced to:
**
**   ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
*/
static void row_numberStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
  i64 *p = (i64*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ) (*p)++;
}
static void row_numberInverseFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
static void row_numberValueFunc(sqlite3_context *pCtx){
  i64 *p = (i64*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  sqlite3_result_int64(pCtx, (p ? *p : 0));
}

/*
** Context object type used by rank() and dense_rank().
*/
struct CallCount {
  i64 nValue;
  i64 nStep;
  i64 nTotal;
};

/*
** Implementation of built-in window function dense_rank().
*/
static void dense_rankStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
  struct CallCount *p;
  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ) p->nStep = 1;
}
static void dense_rankInverseFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
static void dense_rankValueFunc(sqlite3_context *pCtx){
  struct CallCount *p;
  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ){
    if( p->nStep ){
      p->nValue++;
      p->nStep = 0;
    }
    sqlite3_result_int64(pCtx, p->nValue);
  }
}

/*
** Implementation of built-in window function rank().
*/
static void rankStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
  struct CallCount *p;
  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ){
    p->nStep++;
    if( p->nValue==0 ){
      p->nValue = p->nStep;
    }
  }
}
static void rankInverseFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
static void rankValueFunc(sqlite3_context *pCtx){
  struct CallCount *p;
  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ){
    sqlite3_result_int64(pCtx, p->nValue);
    p->nValue = 0;
  }
}

/*
** Implementation of built-in window function percent_rank().
*/
static void percent_rankStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
  struct CallCount *p;
  assert( nArg==1 );

  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ){
    if( p->nTotal==0 ){
      p->nTotal = sqlite3_value_int64(apArg[0]);
    }
    p->nStep++;
    if( p->nValue==0 ){
      p->nValue = p->nStep;
    }
  }
}
static void percent_rankInverseFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
static void percent_rankValueFunc(sqlite3_context *pCtx){
  struct CallCount *p;
  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ){
    if( p->nTotal>1 ){
      double r = (double)(p->nValue-1) / (double)(p->nTotal-1);
      sqlite3_result_double(pCtx, r);
    }else{
      sqlite3_result_double(pCtx, 100.0);
    }
    p->nValue = 0;
  }
}

static void nth_valueStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
static void nth_valueInverseFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
static void nth_valueValueFunc(sqlite3_context *pCtx){
}

#define WINDOWFUNC(name,nArg,extra) {                                      \
  nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0,                      \
  name ## StepFunc, name ## ValueFunc, name ## ValueFunc,                  \
  name ## InverseFunc, #name                                               \
}

/*
** Register those built-in window functions that are not also aggregates.
*/
void sqlite3WindowFunctions(void){
  static FuncDef aWindowFuncs[] = {
    WINDOWFUNC(row_number, 0, 0),
    WINDOWFUNC(dense_rank, 0, 0),
    WINDOWFUNC(rank, 0, 0),
    WINDOWFUNC(percent_rank, 0, SQLITE_FUNC_WINDOW_SIZE),
    WINDOWFUNC(nth_value, 2, 0),
  };
  sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs));
}

void sqlite3WindowUpdate(Parse *pParse, Window *pWin, FuncDef *pFunc){
  if( pFunc->funcFlags & SQLITE_FUNC_WINDOW ){
    sqlite3 *db = pParse->db;
    if( pFunc->xSFunc==row_numberStepFunc ){
      sqlite3ExprDelete(db, pWin->pStart);
      sqlite3ExprDelete(db, pWin->pEnd);
      pWin->pStart = pWin->pEnd = 0;
      pWin->eType = TK_ROWS;
      pWin->eStart = TK_UNBOUNDED;
      pWin->eEnd = TK_CURRENT;
    }

    if( pFunc->xSFunc==dense_rankStepFunc || pFunc->xSFunc==rankStepFunc
     || pFunc->xSFunc==percent_rankStepFunc
    ){
      sqlite3ExprDelete(db, pWin->pStart);
      sqlite3ExprDelete(db, pWin->pEnd);
      pWin->pStart = pWin->pEnd = 0;
      pWin->eType = TK_RANGE;
      pWin->eStart = TK_UNBOUNDED;
      pWin->eEnd = TK_CURRENT;
    }
  }
}

typedef struct WindowRewrite WindowRewrite;
struct WindowRewrite {
  Window *pWin;
  ExprList *pSub;
};

static int selectWindowRewriteSelectCb(Walker *pWalker, Select *pSelect){
  return WRC_Prune;
}

static int selectWindowRewriteExprCb(Walker *pWalker, Expr *pExpr){
  struct WindowRewrite *p = pWalker->u.pRewrite;
  Parse *pParse = pWalker->pParse;

  switch( pExpr->op ){

    case TK_FUNCTION:
      if( pExpr->pWin==0 ){
        break;
      }else{
        Window *pWin;
        for(pWin=p->pWin; pWin; pWin=pWin->pNextWin){
          if( pExpr->pWin==pWin ){
            pExpr->pWin->pOwner = pExpr;
            return WRC_Prune;
          }
        }
      }
      /* Fall through.  */

    case TK_COLUMN: {
      Expr *pDup = sqlite3ExprDup(pParse->db, pExpr, 0);
      p->pSub = sqlite3ExprListAppend(pParse, p->pSub, pDup);
      if( p->pSub ){
        assert( ExprHasProperty(pExpr, EP_Static)==0 );
        ExprSetProperty(pExpr, EP_Static);
        sqlite3ExprDelete(pParse->db, pExpr);
        ExprClearProperty(pExpr, EP_Static);
        memset(pExpr, 0, sizeof(Expr));

        pExpr->op = TK_COLUMN;
        pExpr->iColumn = p->pSub->nExpr-1;
        pExpr->iTable = p->pWin->iEphCsr;
      }

      break;
    }

    default: /* no-op */
      break;
  }

  return WRC_Continue;
}

static int selectWindowRewriteEList(
  Parse *pParse, 
  Window *pWin,
  ExprList *pEList,               /* Rewrite expressions in this list */
  ExprList **ppSub                /* IN/OUT: Sub-select expression-list */
){
  Walker sWalker;
  WindowRewrite sRewrite;
  int rc;

  memset(&sWalker, 0, sizeof(Walker));
  memset(&sRewrite, 0, sizeof(WindowRewrite));

  sRewrite.pSub = *ppSub;
  sRewrite.pWin = pWin;

  sWalker.pParse = pParse;
  sWalker.xExprCallback = selectWindowRewriteExprCb;
  sWalker.xSelectCallback = selectWindowRewriteSelectCb;
  sWalker.u.pRewrite = &sRewrite;

  rc = sqlite3WalkExprList(&sWalker, pEList);

  *ppSub = sRewrite.pSub;
  return rc;
}

static ExprList *exprListAppendList(
  Parse *pParse,          /* Parsing context */
  ExprList *pList,        /* List to which to append. Might be NULL */
  ExprList *pAppend       /* List of values to append. Might be NULL */
){
  if( pAppend ){
    int i;
    int nInit = pList ? pList->nExpr : 0;
    for(i=0; i<pAppend->nExpr; i++){
      Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
      pList = sqlite3ExprListAppend(pParse, pList, pDup);
      if( pList ) pList->a[nInit+i].sortOrder = pAppend->a[i].sortOrder;
    }
  }
  return pList;
}

/*
** If the SELECT statement passed as the second argument does not invoke
** any SQL window functions, this function is a no-op. Otherwise, it 
** rewrites the SELECT statement so that window function xStep functions
** are invoked in the correct order. The simplest version of the 
** transformation is:
**
**   SELECT win(args...) OVER (<list1>) FROM <src> ORDER BY <list2>
**
** to
**
**   SELECT win(args...) FROM (
**     SELECT args... FROM <src> ORDER BY <list1>
**   ) ORDER BY <list2>
**
** where <src> may contain WHERE, GROUP BY and HAVING clauses, and <list1>
** is the concatenation of the PARTITION BY and ORDER BY clauses in the
** OVER clause.
**
*/
int sqlite3WindowRewrite(Parse *pParse, Select *p){
  int rc = SQLITE_OK;
  if( p->pWin ){
    Vdbe *v = sqlite3GetVdbe(pParse);
    int i;
    sqlite3 *db = pParse->db;
    Select *pSub = 0;             /* The subquery */
    SrcList *pSrc = p->pSrc;
    Expr *pWhere = p->pWhere;
    ExprList *pGroupBy = p->pGroupBy;
    Expr *pHaving = p->pHaving;
    ExprList *pSort = 0;

    ExprList *pSublist = 0;       /* Expression list for sub-query */
    Window *pMWin = p->pWin;      /* Master window object */
    Window *pWin;                 /* Window object iterator */

    p->pSrc = 0;
    p->pWhere = 0;
    p->pGroupBy = 0;
    p->pHaving = 0;

    /* Assign a cursor number for the ephemeral table used to buffer rows.
    ** The OpenEphemeral instruction is coded later, after it is known how
    ** many columns the table will have.  */
    pMWin->iEphCsr = pParse->nTab++;

    rc = selectWindowRewriteEList(pParse, pMWin, p->pEList, &pSublist);
    if( rc ) return rc;
    rc = selectWindowRewriteEList(pParse, pMWin, p->pOrderBy, &pSublist);
    if( rc ) return rc;
    pMWin->nBufferCol = (pSublist ? pSublist->nExpr : 0);

    /* Create the ORDER BY clause for the sub-select. This is the concatenation
    ** of the window PARTITION and ORDER BY clauses. Append the same 
    ** expressions to the sub-select expression list. They are required to
    ** figure out where boundaries for partitions and sets of peer rows.  */
    pSort = sqlite3ExprListDup(db, pMWin->pPartition, 0);
    if( pMWin->pOrderBy ){
      pSort = exprListAppendList(pParse, pSort, pMWin->pOrderBy);
    }
    pSublist = exprListAppendList(pParse, pSublist, pSort);

    /* Append the arguments passed to each window function to the
    ** sub-select expression list. Also allocate two registers for each
    ** window function - one for the accumulator, another for interim
    ** results.  */
    for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
      pWin->iArgCol = (pSublist ? pSublist->nExpr : 0);
      pSublist = exprListAppendList(pParse, pSublist, pWin->pOwner->x.pList);
      pWin->regAccum = ++pParse->nMem;
      pWin->regResult = ++pParse->nMem;
      sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
    }

    pSub = sqlite3SelectNew(
        pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
    );
    p->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
    if( p->pSrc ){
      int iTab;
      ExprList *pList = 0;
      p->pSrc->a[0].pSelect = pSub;
      sqlite3SrcListAssignCursors(pParse, p->pSrc);
      if( sqlite3ExpandSubquery(pParse, &p->pSrc->a[0]) ){
        rc = SQLITE_NOMEM;
      }else{
        pSub->selFlags |= SF_Expanded;
      }
    }

    sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pMWin->iEphCsr, pSublist->nExpr);
  }

  return rc;
}

void sqlite3WindowDelete(sqlite3 *db, Window *p){
  if( p ){
    sqlite3ExprDelete(db, p->pFilter);
    sqlite3ExprListDelete(db, p->pPartition);
    sqlite3ExprListDelete(db, p->pOrderBy);
    sqlite3ExprDelete(db, p->pEnd);
................................................................................
** linked list starting at pMWin.
*/
static void windowAggStep(
  Parse *pParse, 
  Window *pMWin, 
  int csr,
  int bInverse, 
  int reg,
  int regPartSize                 /* Register containing size of partition */
){
  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;
  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    int flags = pWin->pFunc->funcFlags;
    int regArg;
    int nArg = pWin->nArg;

    if( flags & SQLITE_FUNC_WINDOW_SIZE ){
      regArg = regPartSize;
      nArg++;
    }else if( csr>=0 ){
      int i;
      for(i=0; i<pWin->nArg; i++){
        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
      }
      regArg = reg;
    }else{
      regArg = reg + pWin->iArgCol;
................................................................................
      if( pWin->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
        CollSeq *pColl;
        pColl = sqlite3ExprCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr);
        sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
      }
      sqlite3VdbeAddOp3(v, OP_AggStep0, bInverse, regArg, pWin->regAccum);
      sqlite3VdbeAppendP4(v, pWin->pFunc, P4_FUNCDEF);
      sqlite3VdbeChangeP5(v, (u8)nArg);
    }
  }
}

static void windowAggFinal(Parse *pParse, Window *pMWin, int bFinal){
  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;
................................................................................
}

static void windowPartitionCache(
  Parse *pParse,
  Select *p,
  WhereInfo *pWInfo,
  int regFlushPart,
  int lblFlushPart,
  int *pRegSize
){
  Window *pMWin = p->pWin;
  Vdbe *v = sqlite3GetVdbe(pParse);
  Window *pWin;
  int iSubCsr = p->pSrc->a[0].iCursor;
  int nSub = p->pSrc->a[0].pTab->nCol;
  int k;

  int reg = pParse->nMem+1;
  int regRecord = reg+nSub;
  int regRowid = regRecord+1;

  *pRegSize = regRowid;
  pParse->nMem += nSub + 2;

  /* Martial the row returned by the sub-select into an array of 
  ** registers. */
  for(k=0; k<nSub; k++){
    sqlite3VdbeAddOp3(v, OP_Column, iSubCsr, k, reg+k);
  }
................................................................................
  int addrIfPos2;

  int regPeer = 0;                 /* Number of peers in current group */
  int regPeerVal = 0;              /* Array of values identifying peer group */
  int iPeer = 0;                   /* Column offset in eph-table of peer vals */
  int nPeerVal;                    /* Number of peer values */
  int bRange = 0;
  int regSize = 0;

  assert( pMWin->eStart==TK_PRECEDING 
       || pMWin->eStart==TK_CURRENT 
       || pMWin->eStart==TK_FOLLOWING 
       || pMWin->eStart==TK_UNBOUNDED 
  );
  assert( pMWin->eEnd==TK_FOLLOWING 
................................................................................
  regFlushPart = ++pParse->nMem;
  lblFlushPart = sqlite3VdbeMakeLabel(v);
  lblFlushDone = sqlite3VdbeMakeLabel(v);

  regStart = ++pParse->nMem;
  regEnd = ++pParse->nMem;

  windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);

  addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);

  /* Start of "flush_partition" */
  sqlite3VdbeResolveLabel(v, lblFlushPart);
  sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+3);
  sqlite3VdbeAddOp2(v, OP_OpenDup, csrStart, pMWin->iEphCsr);
................................................................................
  ** do nothing.  */
  addrTop = sqlite3VdbeCurrentAddr(v);
  if( pMWin->eEnd==TK_PRECEDING ){
    addrIfPos1 = sqlite3VdbeAddOp3(v, OP_IfPos, regEnd, 0 , 1);
  }
  sqlite3VdbeAddOp2(v, OP_Next, csrEnd, sqlite3VdbeCurrentAddr(v)+2);
  addr = sqlite3VdbeAddOp0(v, OP_Goto);
  windowAggStep(pParse, pMWin, csrEnd, 0, regArg, regSize);
  if( pMWin->eEnd==TK_UNBOUNDED ){
    sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop);
    sqlite3VdbeJumpHere(v, addr);
    addrTop = sqlite3VdbeCurrentAddr(v);
  }else{
    sqlite3VdbeJumpHere(v, addr);
    if( pMWin->eEnd==TK_PRECEDING ){
................................................................................
      addrJumpHere = sqlite3VdbeAddOp3(v, OP_IfPos, regStart, 0 , 1);
    }
    if( bRange ){
      sqlite3VdbeAddOp3(v, OP_IfPos, regPeer, sqlite3VdbeCurrentAddr(v)+2, 1);
      addrJumpHere = sqlite3VdbeAddOp0(v, OP_Goto);
    }
    sqlite3VdbeAddOp2(v, OP_Next, csrStart, sqlite3VdbeCurrentAddr(v)+1);
    windowAggStep(pParse, pMWin, csrStart, 1, regArg, regSize);
    if( bRange ){
      sqlite3VdbeAddOp2(v, OP_Goto, 0, addrJumpHere-1);
    }
    if( addrJumpHere ){
      sqlite3VdbeJumpHere(v, addrJumpHere);
    }
  }
................................................................................
  int addrGoto;                   /* Address of Goto used to jump flush_par.. */
  int addrRewind;                 /* Address of Rewind that starts loop */
  int regFlushPart;
  int lblFlushPart;
  int csrLead;
  int regCtr;
  int regArg;                     /* Register array to martial function args */
  int regSize;
  int nArg;

  assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT) 
  );

  regNewPeer = pParse->nMem+1;
  pParse->nMem += nPeer;
................................................................................
  /* Allocate register and label for the "flush_partition" sub-routine. */
  regFlushPart = ++pParse->nMem;
  lblFlushPart = sqlite3VdbeMakeLabel(v);

  csrLead = pParse->nTab++;
  regCtr = ++pParse->nMem;

  windowPartitionCache(pParse, p, pWInfo, regFlushPart, lblFlushPart, &regSize);
  addrGoto = sqlite3VdbeAddOp0(v, OP_Goto);

  /* Start of "flush_partition" */
  sqlite3VdbeResolveLabel(v, lblFlushPart);
  sqlite3VdbeAddOp2(v, OP_Once, 0, sqlite3VdbeCurrentAddr(v)+2);
  sqlite3VdbeAddOp2(v, OP_OpenDup, csrLead, pMWin->iEphCsr);

................................................................................
    sqlite3VdbeAddOp3(v, OP_IfPos, regCtr, sqlite3VdbeCurrentAddr(v)+2 , 1);
    sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+3);
    sqlite3VdbeAddOp2(v, OP_Gosub, regGosub, addrGosub);
    sqlite3VdbeAddOp2(v, OP_Next, pMWin->iEphCsr, sqlite3VdbeCurrentAddr(v)-3);
    sqlite3VdbeJumpHere(v, addrJump);
  }

  windowAggStep(pParse, pMWin, csrLead, 0, regArg, regSize);
  sqlite3VdbeAddOp2(v, OP_AddImm, regCtr, 1);

  sqlite3VdbeAddOp2(v, OP_Next, csrLead, addrRewind+2);

  windowAggFinal(pParse, pMWin, 1);

  sqlite3VdbeAddOp3(v, OP_IfPos, regCtr, sqlite3VdbeCurrentAddr(v)+2 , 1);
................................................................................
        v, OP_Copy, reg+pMWin->nBufferCol, pMWin->regPart, nPart+nPeer-1
    );

    if( addrJump ) sqlite3VdbeJumpHere(v, addrJump);
  }

  /* Invoke step function for window functions */
  windowAggStep(pParse, pMWin, -1, 0, reg, 0);

  /* Buffer the current row in the ephemeral table. */
  if( pMWin->nBufferCol>0 ){
    sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, pMWin->nBufferCol, regRecord);
  }else{
    sqlite3VdbeAddOp2(v, OP_Blob, 0, regRecord);
    sqlite3VdbeAppendP4(v, (void*)"", 0);
................................................................................
  Select *p,
  WhereInfo *pWInfo,
  int regGosub, 
  int addrGosub,
  int *pbLoop
){
  Window *pMWin = p->pWin;
  Window *pWin;

  *pbLoop = 0;
  if( (pMWin->eType==TK_ROWS 
   && (pMWin->eStart!=TK_UNBOUNDED||pMWin->eEnd!=TK_CURRENT||!pMWin->pOrderBy))
   || (pMWin->eStart==TK_CURRENT&&pMWin->eEnd==TK_UNBOUNDED&&pMWin->pOrderBy)
  ){
    windowCodeRowExprStep(pParse, p, pWInfo, regGosub, addrGosub);
    return;
  }

  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    if( pWin->pFunc->funcFlags & SQLITE_FUNC_WINDOW_SIZE ){




      windowCodeCacheStep(pParse, p, pWInfo, regGosub, addrGosub);
      return;
    }

  }

  *pbLoop = 1;
  windowCodeDefaultStep(pParse, p, pWInfo, regGosub, addrGosub);
}


Changes to test/window3.tcl.

69
70
71
72
73
74
75
76
77
78






















































































79
80
81
  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.2.1.$tn "SELECT max(b) OVER ( ORDER BY a $window ) FROM t2"
  execsql_test 1.2.2.$tn "SELECT min(b) OVER ( ORDER BY a $window ) FROM t2"
}























































































finish_test








|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
  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
  "
  execsql_test 1.$tn.3.2 "
    SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
  "

  execsql_test 1.$tn.4.1 "
    SELECT dense_rank() OVER ( ORDER BY a $window ) FROM t2
  "
  execsql_test 1.$tn.4.2 "
    SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
  "
  execsql_test 1.$tn.4.3 "
    SELECT dense_rank() OVER ( ORDER BY b $window ) FROM t2
  "
  execsql_test 1.$tn.4.4 "
    SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
  "
  execsql_test 1.$tn.4.5 "
    SELECT dense_rank() OVER ( ORDER BY b%10 $window ) FROM t2
  "
  execsql_test 1.$tn.4.6 "
    SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
  "

  execsql_test 1.$tn.5.1 "
    SELECT rank() OVER ( ORDER BY a $window ) FROM t2
  "
  execsql_test 1.$tn.5.2 "
    SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
  "
  execsql_test 1.$tn.5.3 "
    SELECT rank() OVER ( ORDER BY b $window ) FROM t2
  "
  execsql_test 1.$tn.5.4 "
    SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
  "
  execsql_test 1.$tn.5.5 "
    SELECT rank() OVER ( ORDER BY b%10 $window ) FROM t2
  "
  execsql_test 1.$tn.5.6 "
    SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
  "

  execsql_test 1.$tn.6.1 "
    SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window )
    FROM t2
  "

  execsql_test 1.$tn.7.1 "
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a $window )
  ) AS integer) FROM t2"

  #execsql_test 1.$tn.7.2 "
  #SELECT CAST( round( 100 * 
      #percent_rank() OVER ( PARTITION BY b%10 ORDER BY a $window )
  #) AS integer) FROM t2"

  execsql_test 1.$tn.7.3 "
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b $window )
  ) AS integer) FROM t2"

  #execsql_test 1.$tn.7.4 "
  #SELECT CAST( round( 100 * 
      #percent_rank() OVER ( PARTITION BY b%10 ORDER BY b $window )
  #) AS integer) FROM t2"

  execsql_test 1.$tn.7.5 "
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 $window )
  ) AS integer) FROM t2"

  execsql_test 1.$tn.7.6 "
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window )
  ) AS integer) FROM t2"


}


finish_test

Changes to test/window3.test.

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































do_execsql_test 1.1 {
  SELECT max(b) OVER (
    ORDER BY a
  ) FROM t2
} {0   74   74   74   74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.2.1.1 {
  SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {0   74   74   74   74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.2.2.1 {
  SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.2.1.2 {
  SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.2.2.2 {
  SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.2.1.3 {
  SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {0   74   41   74   23   99   26   33   2   89   81   96   59   38   68   39   62   91   46   6   99   97   27   46   78   54   97   8   67   29   93   84   77   23   16   16   93   65   35   47   7   86   74   61   91   85   24   85   43   59   12   32   56   3   91   22   90   55   15   28   89   25   47   1   56   40   43   56   16   75   36   89   98   76   81   4   94   42   30   78   33   29   53   63   2   87   37   80   84   72   41   9   61   73   95   65   13   58   96   98   1   21   74   65   35   5   73   11   51   87   41   12   8   20   31   31   15   95   22   73   79   88   34   8   11   49   34   90   59   96   60   55   75   77   44   2   7   85   57   74   29   70   59   19   39   26   26   47   80   90   36   58   47   9   72   72   66   33   93   75   64   81   9   23   37   13   12   14   62   91   36   91   33   15   34   36   99   3   95   69   58   52   30   50   84   10   84   33   21   39   44   58   30   38   34   83   27   82   17   7}

do_execsql_test 1.2.2.3 {
  SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {0   74   41   74   23   99   26   33   2   89   81   96   59   38   68   39   62   91   46   6   99   97   27   46   78   54   97   8   67   29   93   84   77   23   16   16   93   65   35   47   7   86   74   61   91   85   24   85   43   59   12   32   56   3   91   22   90   55   15   28   89   25   47   1   56   40   43   56   16   75   36   89   98   76   81   4   94   42   30   78   33   29   53   63   2   87   37   80   84   72   41   9   61   73   95   65   13   58   96   98   1   21   74   65   35   5   73   11   51   87   41   12   8   20   31   31   15   95   22   73   79   88   34   8   11   49   34   90   59   96   60   55   75   77   44   2   7   85   57   74   29   70   59   19   39   26   26   47   80   90   36   58   47   9   72   72   66   33   93   75   64   81   9   23   37   13   12   14   62   91   36   91   33   15   34   36   99   3   95   69   58   52   30   50   84   10   84   33   21   39   44   58   30   38   34   83   27   82   17   7}

do_execsql_test 1.2.1.4 {
  SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   83   83   83   83   83   83   83   83   83   82   82   17   7}

do_execsql_test 1.2.2.4 {
  SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7}

do_execsql_test 1.2.1.5 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {{}   {}   {}   {}   0   74   74   74   74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.2.2.5 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {{}   {}   {}   {}   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.2.1.6 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {{}   {}   0   74   74   74   74   99   99   99   33   89   89   96   96   96   68   68   68   91   91   91   99   99   99   97   78   78   97   97   97   67   93   93   93   84   77   23   93   93   93   65   47   86   86   86   91   91   91   85   85   85   59   59   56   56   91   91   91   90   90   55   89   89   89   47   56   56   56   56   56   75   75   89   98   98   98   81   94   94   94   78   78   78   53   63   63   87   87   87   84   84   84   72   61   73   95   95   95   65   96   98   98   98   74   74   74   65   73   73   73   87   87   87   41   20   31   31   31   95   95   95   79   88   88   88   34   49   49   90   90   96   96   96   75   77   77   77   44   85   85   85   74   74   70   70   59   39   39   47   80   90   90   90   58   58   72   72   72   72   93   93   93   81   81   81   37   37   37   14   62   91   91   91   91   91   34   36   99   99   99   95   95   69   58   52   84   84   84   84   84   39   44   58   58   58   38   83   83   83}

do_execsql_test 1.2.2.6 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {{}   {}   0   0   0   41   23   23   23   26   2   2   2   81   59   38   38   38   39   39   46   6   6   6   27   27   27   46   54   8   8   8   29   29   77   23   16   16   16   16   35   35   7   7   7   61   61   61   24   24   24   43   12   12   12   3   3   3   22   22   15   15   15   25   25   1   1   1   40   40   16   16   16   36   36   76   76   4   4   4   30   30   30   29   29   29   2   2   2   37   37   72   41   9   9   9   61   65   13   13   13   58   1   1   1   21   35   5   5   5   11   11   41   12   8   8   8   20   15   15   15   22   22   73   34   8   8   8   11   34   34   59   59   55   55   55   44   2   2   2   7   57   29   29   29   19   19   19   26   26   26   47   36   36   36   9   9   9   66   33   33   33   64   64   9   9   9   13   12   12   12   14   36   36   33   15   15   15   34   3   3   3   58   52   30   30   30   10   10   10   21   21   21   39   30   30   30   34   27   27}

do_execsql_test 1.2.1.7 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {0   74   74   74   74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.2.2.7 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.2.1.8 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {0   74   74   74   74   99   99   99   99   99   89   96   96   96   96   96   68   91   91   91   99   99   99   99   99   97   97   97   97   97   97   93   93   93   93   84   93   93   93   93   93   86   86   86   91   91   91   91   91   85   85   85   59   59   91   91   91   91   91   90   90   89   89   89   89   56   56   56   56   75   75   89   98   98   98   98   98   94   94   94   94   78   78   78   63   87   87   87   87   87   84   84   84   73   95   95   95   95   96   98   98   98   98   98   74   74   74   73   73   87   87   87   87   87   41   31   31   95   95   95   95   95   88   88   88   88   49   90   90   96   96   96   96   96   77   77   77   85   85   85   85   85   74   74   70   70   59   47   80   90   90   90   90   90   72   72   72   72   93   93   93   93   93   81   81   81   37   37   62   91   91   91   91   91   91   91   99   99   99   99   99   95   95   69   84   84   84   84   84   84   84   58   58   58   58   83   83   83   83   83}

do_execsql_test 1.2.2.8 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {0   0   0   0   0   23   23   23   2   2   2   2   2   38   38   38   38   38   39   6   6   6   6   6   27   27   27   8   8   8   8   8   29   23   16   16   16   16   16   16   7   7   7   7   7   61   24   24   24   24   12   12   12   3   3   3   3   3   15   15   15   15   15   1   1   1   1   1   16   16   16   16   16   36   36   4   4   4   4   4   30   29   29   29   2   2   2   2   2   37   37   9   9   9   9   9   13   13   13   13   1   1   1   1   1   5   5   5   5   5   11   11   8   8   8   8   8   15   15   15   15   22   22   8   8   8   8   8   11   34   34   55   55   55   44   2   2   2   2   2   7   29   29   19   19   19   19   19   26   26   26   36   36   9   9   9   9   9   33   33   33   33   9   9   9   9   9   12   12   12   12   14   33   15   15   15   15   3   3   3   3   3   30   30   30   10   10   10   10   10   21   21   21   30   30   30   27   27   17   7}

do_execsql_test 1.2.1.9 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {0   74   41   74   23   99   26   33   2   89   81   96   59   38   68   39   62   91   46   6   99   97   27   46   78   54   97   8   67   29   93   84   77   23   16   16   93   65   35   47   7   86   74   61   91   85   24   85   43   59   12   32   56   3   91   22   90   55   15   28   89   25   47   1   56   40   43   56   16   75   36   89   98   76   81   4   94   42   30   78   33   29   53   63   2   87   37   80   84   72   41   9   61   73   95   65   13   58   96   98   1   21   74   65   35   5   73   11   51   87   41   12   8   20   31   31   15   95   22   73   79   88   34   8   11   49   34   90   59   96   60   55   75   77   44   2   7   85   57   74   29   70   59   19   39   26   26   47   80   90   36   58   47   9   72   72   66   33   93   75   64   81   9   23   37   13   12   14   62   91   36   91   33   15   34   36   99   3   95   69   58   52   30   50   84   10   84   33   21   39   44   58   30   38   34   83   27   82   17   7}

do_execsql_test 1.2.2.9 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {0   74   41   74   23   99   26   33   2   89   81   96   59   38   68   39   62   91   46   6   99   97   27   46   78   54   97   8   67   29   93   84   77   23   16   16   93   65   35   47   7   86   74   61   91   85   24   85   43   59   12   32   56   3   91   22   90   55   15   28   89   25   47   1   56   40   43   56   16   75   36   89   98   76   81   4   94   42   30   78   33   29   53   63   2   87   37   80   84   72   41   9   61   73   95   65   13   58   96   98   1   21   74   65   35   5   73   11   51   87   41   12   8   20   31   31   15   95   22   73   79   88   34   8   11   49   34   90   59   96   60   55   75   77   44   2   7   85   57   74   29   70   59   19   39   26   26   47   80   90   36   58   47   9   72   72   66   33   93   75   64   81   9   23   37   13   12   14   62   91   36   91   33   15   34   36   99   3   95   69   58   52   30   50   84   10   84   33   21   39   44   58   30   38   34   83   27   82   17   7}

do_execsql_test 1.2.1.10 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.2.2.10 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.2.1.11 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {74   74   74   99   99   99   99   99   99   99   96   96   96   96   96   96   91   91   99   99   99   99   99   99   99   97   97   97   97   97   97   93   93   93   93   93   93   93   93   93   93   86   91   91   91   91   91   91   91   85   85   85   91   91   91   91   91   91   91   90   90   89   89   89   89   56   56   75   75   89   98   98   98   98   98   98   98   94   94   94   94   78   78   87   87   87   87   87   87   87   84   84   95   95   95   95   96   98   98   98   98   98   98   98   74   74   74   87   87   87   87   87   87   87   41   95   95   95   95   95   95   95   88   88   88   90   90   96   96   96   96   96   96   96   77   85   85   85   85   85   85   85   74   74   70   70   80   90   90   90   90   90   90   90   72   72   93   93   93   93   93   93   93   81   81   81   62   91   91   91   91   91   91   91   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   58   58   83   83   83   83   83   83   83}

do_execsql_test 1.2.2.11 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {0   0   0   0   0   23   2   2   2   2   2   2   2   38   38   38   38   6   6   6   6   6   6   6   27   8   8   8   8   8   8   8   16   16   16   16   16   16   7   7   7   7   7   7   7   24   24   24   12   12   12   3   3   3   3   3   3   3   15   15   15   1   1   1   1   1   1   1   16   16   16   16   16   4   4   4   4   4   4   4   29   29   2   2   2   2   2   2   2   9   9   9   9   9   9   9   13   13   1   1   1   1   1   1   1   5   5   5   5   5   8   8   8   8   8   8   8   15   15   15   15   8   8   8   8   8   8   8   11   34   34   55   44   2   2   2   2   2   2   2   7   19   19   19   19   19   19   19   26   26   26   9   9   9   9   9   9   9   33   33   9   9   9   9   9   9   9   12   12   12   12   14   15   15   15   3   3   3   3   3   3   3   30   10   10   10   10   10   10   10   21   21   21   30   27   27   17   7   7   7}

do_execsql_test 1.2.1.12 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {74   99   99   99   99   99   89   96   96   96   96   96   68   91   91   91   99   99   99   99   99   97   97   97   97   97   97   93   93   93   93   84   93   93   93   93   93   86   86   86   91   91   91   91   91   85   85   85   59   59   91   91   91   91   91   90   90   89   89   89   89   56   56   56   56   75   75   89   98   98   98   98   98   94   94   94   94   78   78   78   63   87   87   87   87   87   84   84   84   73   95   95   95   95   96   98   98   98   98   98   74   74   74   73   73   87   87   87   87   87   41   31   31   95   95   95   95   95   88   88   88   88   49   90   90   96   96   96   96   96   77   77   77   85   85   85   85   85   74   74   70   70   59   47   80   90   90   90   90   90   72   72   72   72   93   93   93   93   93   81   81   81   37   37   62   91   91   91   91   91   91   91   99   99   99   99   99   95   95   69   84   84   84   84   84   84   84   58   58   58   58   83   83   83   83   83   82   82   17   7}

do_execsql_test 1.2.2.12 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {0   23   23   23   2   2   2   2   2   38   38   38   38   38   39   6   6   6   6   6   27   27   27   8   8   8   8   8   29   23   16   16   16   16   16   16   7   7   7   7   7   61   24   24   24   24   12   12   12   3   3   3   3   3   15   15   15   15   15   1   1   1   1   1   16   16   16   16   16   36   36   4   4   4   4   4   30   29   29   29   2   2   2   2   2   37   37   9   9   9   9   9   13   13   13   13   1   1   1   1   1   5   5   5   5   5   11   11   8   8   8   8   8   15   15   15   15   22   22   8   8   8   8   8   11   34   34   55   55   55   44   2   2   2   2   2   7   29   29   19   19   19   19   19   26   26   26   36   36   9   9   9   9   9   33   33   33   33   9   9   9   9   9   12   12   12   12   14   33   15   15   15   15   3   3   3   3   3   30   30   30   10   10   10   10   10   21   21   21   30   30   30   27   27   17   7   7   7   7   7}

do_execsql_test 1.2.1.13 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {74   99   99   99   33   89   89   96   96   96   68   68   68   91   91   91   99   99   99   97   78   78   97   97   97   67   93   93   93   84   77   23   93   93   93   65   47   86   86   86   91   91   91   85   85   85   59   59   56   56   91   91   91   90   90   55   89   89   89   47   56   56   56   56   56   75   75   89   98   98   98   81   94   94   94   78   78   78   53   63   63   87   87   87   84   84   84   72   61   73   95   95   95   65   96   98   98   98   74   74   74   65   73   73   73   87   87   87   41   20   31   31   31   95   95   95   79   88   88   88   34   49   49   90   90   96   96   96   75   77   77   77   44   85   85   85   74   74   70   70   59   39   39   47   80   90   90   90   58   58   72   72   72   72   93   93   93   81   81   81   37   37   37   14   62   91   91   91   91   91   34   36   99   99   99   95   95   69   58   52   84   84   84   84   84   39   44   58   58   58   38   83   83   83   82   82   17   7   {}   {}}

do_execsql_test 1.2.2.13 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {23   23   23   26   2   2   2   81   59   38   38   38   39   39   46   6   6   6   27   27   27   46   54   8   8   8   29   29   77   23   16   16   16   16   35   35   7   7   7   61   61   61   24   24   24   43   12   12   12   3   3   3   22   22   15   15   15   25   25   1   1   1   40   40   16   16   16   36   36   76   76   4   4   4   30   30   30   29   29   29   2   2   2   37   37   72   41   9   9   9   61   65   13   13   13   58   1   1   1   21   35   5   5   5   11   11   41   12   8   8   8   20   15   15   15   22   22   73   34   8   8   8   11   34   34   59   59   55   55   55   44   2   2   2   7   57   29   29   29   19   19   19   26   26   26   47   36   36   36   9   9   9   66   33   33   33   64   64   9   9   9   13   12   12   12   14   36   36   33   15   15   15   34   3   3   3   58   52   30   30   30   10   10   10   21   21   21   39   30   30   30   34   27   27   17   7   7   7   {}   {}}

do_execsql_test 1.2.1.14 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.2.2.14 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.2.1.15 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   83   83   83   83   83   83   83   83   83}

do_execsql_test 1.2.2.15 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {0   0   0   0   0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7}

do_execsql_test 1.2.1.16 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   83   83   83   83   83   83   83   83   83   82   82   17   7}

do_execsql_test 1.2.2.16 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7}

do_execsql_test 1.2.1.17 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   83   83   83   83   83   83   83   83   83   82   82   17   7   {}   {}   {}   {}}

do_execsql_test 1.2.2.17 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   {}   {}   {}   {}}

finish_test































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































|



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
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
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
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
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
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
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
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
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
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692

do_execsql_test 1.1 {
  SELECT max(b) OVER (
    ORDER BY a
  ) FROM t2
} {0   74   74   74   74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.1.2.1 {
  SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {0   74   74   74   74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.1.2.2 {
  SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.1.3.1 {
  SELECT row_number() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.1.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.1.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.1.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.1.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.1.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.1.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.1.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.1.5.1 {
  SELECT rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.1.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.1.5.3 {
  SELECT rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.1.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.1.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.1.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.1.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.1.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.1.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.1.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.1.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.2.2.1 {
  SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.2.2.2 {
  SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.2.3.1 {
  SELECT row_number() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.2.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.2.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.2.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.2.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.2.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.2.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.2.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.2.5.1 {
  SELECT rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.2.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.2.5.3 {
  SELECT rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.2.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.2.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.2.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.2.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.2.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.2.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.2.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.2.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.3.2.1 {
  SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {0   74   41   74   23   99   26   33   2   89   81   96   59   38   68   39   62   91   46   6   99   97   27   46   78   54   97   8   67   29   93   84   77   23   16   16   93   65   35   47   7   86   74   61   91   85   24   85   43   59   12   32   56   3   91   22   90   55   15   28   89   25   47   1   56   40   43   56   16   75   36   89   98   76   81   4   94   42   30   78   33   29   53   63   2   87   37   80   84   72   41   9   61   73   95   65   13   58   96   98   1   21   74   65   35   5   73   11   51   87   41   12   8   20   31   31   15   95   22   73   79   88   34   8   11   49   34   90   59   96   60   55   75   77   44   2   7   85   57   74   29   70   59   19   39   26   26   47   80   90   36   58   47   9   72   72   66   33   93   75   64   81   9   23   37   13   12   14   62   91   36   91   33   15   34   36   99   3   95   69   58   52   30   50   84   10   84   33   21   39   44   58   30   38   34   83   27   82   17   7}

do_execsql_test 1.3.2.2 {
  SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {0   74   41   74   23   99   26   33   2   89   81   96   59   38   68   39   62   91   46   6   99   97   27   46   78   54   97   8   67   29   93   84   77   23   16   16   93   65   35   47   7   86   74   61   91   85   24   85   43   59   12   32   56   3   91   22   90   55   15   28   89   25   47   1   56   40   43   56   16   75   36   89   98   76   81   4   94   42   30   78   33   29   53   63   2   87   37   80   84   72   41   9   61   73   95   65   13   58   96   98   1   21   74   65   35   5   73   11   51   87   41   12   8   20   31   31   15   95   22   73   79   88   34   8   11   49   34   90   59   96   60   55   75   77   44   2   7   85   57   74   29   70   59   19   39   26   26   47   80   90   36   58   47   9   72   72   66   33   93   75   64   81   9   23   37   13   12   14   62   91   36   91   33   15   34   36   99   3   95   69   58   52   30   50   84   10   84   33   21   39   44   58   30   38   34   83   27   82   17   7}

do_execsql_test 1.3.3.1 {
  SELECT row_number() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.3.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.3.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.3.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.3.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.3.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.3.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.3.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.3.5.1 {
  SELECT rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.3.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.3.5.3 {
  SELECT rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.3.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.3.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.3.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.3.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.3.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.3.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.3.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.3.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.4.2.1 {
  SELECT max(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   83   83   83   83   83   83   83   83   83   82   82   17   7}

do_execsql_test 1.4.2.2 {
  SELECT min(b) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7}

do_execsql_test 1.4.3.1 {
  SELECT row_number() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.4.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.4.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.4.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.4.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.4.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.4.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.4.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.4.5.1 {
  SELECT rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.4.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.4.5.3 {
  SELECT rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.4.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.4.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.4.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.4.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.4.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.4.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.4.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.4.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.5.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {{}   {}   {}   {}   0   74   74   74   74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.5.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {{}   {}   {}   {}   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.5.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.5.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.5.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.5.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.5.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.5.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.5.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.5.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.5.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.5.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.5.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.5.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.5.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.5.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.5.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.5.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.5.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.5.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.5.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.6.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {{}   {}   0   74   74   74   74   99   99   99   33   89   89   96   96   96   68   68   68   91   91   91   99   99   99   97   78   78   97   97   97   67   93   93   93   84   77   23   93   93   93   65   47   86   86   86   91   91   91   85   85   85   59   59   56   56   91   91   91   90   90   55   89   89   89   47   56   56   56   56   56   75   75   89   98   98   98   81   94   94   94   78   78   78   53   63   63   87   87   87   84   84   84   72   61   73   95   95   95   65   96   98   98   98   74   74   74   65   73   73   73   87   87   87   41   20   31   31   31   95   95   95   79   88   88   88   34   49   49   90   90   96   96   96   75   77   77   77   44   85   85   85   74   74   70   70   59   39   39   47   80   90   90   90   58   58   72   72   72   72   93   93   93   81   81   81   37   37   37   14   62   91   91   91   91   91   34   36   99   99   99   95   95   69   58   52   84   84   84   84   84   39   44   58   58   58   38   83   83   83}

do_execsql_test 1.6.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {{}   {}   0   0   0   41   23   23   23   26   2   2   2   81   59   38   38   38   39   39   46   6   6   6   27   27   27   46   54   8   8   8   29   29   77   23   16   16   16   16   35   35   7   7   7   61   61   61   24   24   24   43   12   12   12   3   3   3   22   22   15   15   15   25   25   1   1   1   40   40   16   16   16   36   36   76   76   4   4   4   30   30   30   29   29   29   2   2   2   37   37   72   41   9   9   9   61   65   13   13   13   58   1   1   1   21   35   5   5   5   11   11   41   12   8   8   8   20   15   15   15   22   22   73   34   8   8   8   11   34   34   59   59   55   55   55   44   2   2   2   7   57   29   29   29   19   19   19   26   26   26   47   36   36   36   9   9   9   66   33   33   33   64   64   9   9   9   13   12   12   12   14   36   36   33   15   15   15   34   3   3   3   58   52   30   30   30   10   10   10   21   21   21   39   30   30   30   34   27   27}

do_execsql_test 1.6.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.6.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.6.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.6.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.6.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.6.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.6.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.6.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.6.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.6.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.6.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.6.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.6.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.6.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.6.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.6.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.6.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.6.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.6.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.7.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {0   74   74   74   74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.7.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.7.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.7.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.7.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.7.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.7.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.7.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.7.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.7.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.7.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.7.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.7.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.7.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.7.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.7.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.7.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.7.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.7.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.7.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.7.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.8.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {0   74   74   74   74   99   99   99   99   99   89   96   96   96   96   96   68   91   91   91   99   99   99   99   99   97   97   97   97   97   97   93   93   93   93   84   93   93   93   93   93   86   86   86   91   91   91   91   91   85   85   85   59   59   91   91   91   91   91   90   90   89   89   89   89   56   56   56   56   75   75   89   98   98   98   98   98   94   94   94   94   78   78   78   63   87   87   87   87   87   84   84   84   73   95   95   95   95   96   98   98   98   98   98   74   74   74   73   73   87   87   87   87   87   41   31   31   95   95   95   95   95   88   88   88   88   49   90   90   96   96   96   96   96   77   77   77   85   85   85   85   85   74   74   70   70   59   47   80   90   90   90   90   90   72   72   72   72   93   93   93   93   93   81   81   81   37   37   62   91   91   91   91   91   91   91   99   99   99   99   99   95   95   69   84   84   84   84   84   84   84   58   58   58   58   83   83   83   83   83}

do_execsql_test 1.8.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {0   0   0   0   0   23   23   23   2   2   2   2   2   38   38   38   38   38   39   6   6   6   6   6   27   27   27   8   8   8   8   8   29   23   16   16   16   16   16   16   7   7   7   7   7   61   24   24   24   24   12   12   12   3   3   3   3   3   15   15   15   15   15   1   1   1   1   1   16   16   16   16   16   36   36   4   4   4   4   4   30   29   29   29   2   2   2   2   2   37   37   9   9   9   9   9   13   13   13   13   1   1   1   1   1   5   5   5   5   5   11   11   8   8   8   8   8   15   15   15   15   22   22   8   8   8   8   8   11   34   34   55   55   55   44   2   2   2   2   2   7   29   29   19   19   19   19   19   26   26   26   36   36   9   9   9   9   9   33   33   33   33   9   9   9   9   9   12   12   12   12   14   33   15   15   15   15   3   3   3   3   3   30   30   30   10   10   10   10   10   21   21   21   30   30   30   27   27   17   7}

do_execsql_test 1.8.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.8.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.8.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.8.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.8.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.8.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.8.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.8.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.8.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.8.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.8.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.8.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.8.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.8.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.8.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.8.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.8.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.8.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.8.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.9.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {0   74   41   74   23   99   26   33   2   89   81   96   59   38   68   39   62   91   46   6   99   97   27   46   78   54   97   8   67   29   93   84   77   23   16   16   93   65   35   47   7   86   74   61   91   85   24   85   43   59   12   32   56   3   91   22   90   55   15   28   89   25   47   1   56   40   43   56   16   75   36   89   98   76   81   4   94   42   30   78   33   29   53   63   2   87   37   80   84   72   41   9   61   73   95   65   13   58   96   98   1   21   74   65   35   5   73   11   51   87   41   12   8   20   31   31   15   95   22   73   79   88   34   8   11   49   34   90   59   96   60   55   75   77   44   2   7   85   57   74   29   70   59   19   39   26   26   47   80   90   36   58   47   9   72   72   66   33   93   75   64   81   9   23   37   13   12   14   62   91   36   91   33   15   34   36   99   3   95   69   58   52   30   50   84   10   84   33   21   39   44   58   30   38   34   83   27   82   17   7}

do_execsql_test 1.9.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {0   74   41   74   23   99   26   33   2   89   81   96   59   38   68   39   62   91   46   6   99   97   27   46   78   54   97   8   67   29   93   84   77   23   16   16   93   65   35   47   7   86   74   61   91   85   24   85   43   59   12   32   56   3   91   22   90   55   15   28   89   25   47   1   56   40   43   56   16   75   36   89   98   76   81   4   94   42   30   78   33   29   53   63   2   87   37   80   84   72   41   9   61   73   95   65   13   58   96   98   1   21   74   65   35   5   73   11   51   87   41   12   8   20   31   31   15   95   22   73   79   88   34   8   11   49   34   90   59   96   60   55   75   77   44   2   7   85   57   74   29   70   59   19   39   26   26   47   80   90   36   58   47   9   72   72   66   33   93   75   64   81   9   23   37   13   12   14   62   91   36   91   33   15   34   36   99   3   95   69   58   52   30   50   84   10   84   33   21   39   44   58   30   38   34   83   27   82   17   7}

do_execsql_test 1.9.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.9.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.9.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.9.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.9.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.9.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.9.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.9.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.9.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.9.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.9.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.9.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.9.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.9.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.9.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.9.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.9.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.9.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.9.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.10.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {74   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.10.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.10.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.10.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.10.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.10.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.10.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.10.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.10.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.10.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.10.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.10.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.10.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.10.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.10.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.10.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.10.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.10.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.10.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.10.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.10.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.11.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {74   74   74   99   99   99   99   99   99   99   96   96   96   96   96   96   91   91   99   99   99   99   99   99   99   97   97   97   97   97   97   93   93   93   93   93   93   93   93   93   93   86   91   91   91   91   91   91   91   85   85   85   91   91   91   91   91   91   91   90   90   89   89   89   89   56   56   75   75   89   98   98   98   98   98   98   98   94   94   94   94   78   78   87   87   87   87   87   87   87   84   84   95   95   95   95   96   98   98   98   98   98   98   98   74   74   74   87   87   87   87   87   87   87   41   95   95   95   95   95   95   95   88   88   88   90   90   96   96   96   96   96   96   96   77   85   85   85   85   85   85   85   74   74   70   70   80   90   90   90   90   90   90   90   72   72   93   93   93   93   93   93   93   81   81   81   62   91   91   91   91   91   91   91   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   58   58   83   83   83   83   83   83   83}

do_execsql_test 1.11.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {0   0   0   0   0   23   2   2   2   2   2   2   2   38   38   38   38   6   6   6   6   6   6   6   27   8   8   8   8   8   8   8   16   16   16   16   16   16   7   7   7   7   7   7   7   24   24   24   12   12   12   3   3   3   3   3   3   3   15   15   15   1   1   1   1   1   1   1   16   16   16   16   16   4   4   4   4   4   4   4   29   29   2   2   2   2   2   2   2   9   9   9   9   9   9   9   13   13   1   1   1   1   1   1   1   5   5   5   5   5   8   8   8   8   8   8   8   15   15   15   15   8   8   8   8   8   8   8   11   34   34   55   44   2   2   2   2   2   2   2   7   19   19   19   19   19   19   19   26   26   26   9   9   9   9   9   9   9   33   33   9   9   9   9   9   9   9   12   12   12   12   14   15   15   15   3   3   3   3   3   3   3   30   10   10   10   10   10   10   10   21   21   21   30   27   27   17   7   7   7}

do_execsql_test 1.11.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.11.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.11.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.11.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.11.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.11.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.11.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.11.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.11.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.11.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.11.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.11.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.11.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.11.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.11.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.11.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.11.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.11.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.11.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.12.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {74   99   99   99   99   99   89   96   96   96   96   96   68   91   91   91   99   99   99   99   99   97   97   97   97   97   97   93   93   93   93   84   93   93   93   93   93   86   86   86   91   91   91   91   91   85   85   85   59   59   91   91   91   91   91   90   90   89   89   89   89   56   56   56   56   75   75   89   98   98   98   98   98   94   94   94   94   78   78   78   63   87   87   87   87   87   84   84   84   73   95   95   95   95   96   98   98   98   98   98   74   74   74   73   73   87   87   87   87   87   41   31   31   95   95   95   95   95   88   88   88   88   49   90   90   96   96   96   96   96   77   77   77   85   85   85   85   85   74   74   70   70   59   47   80   90   90   90   90   90   72   72   72   72   93   93   93   93   93   81   81   81   37   37   62   91   91   91   91   91   91   91   99   99   99   99   99   95   95   69   84   84   84   84   84   84   84   58   58   58   58   83   83   83   83   83   82   82   17   7}

do_execsql_test 1.12.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {0   23   23   23   2   2   2   2   2   38   38   38   38   38   39   6   6   6   6   6   27   27   27   8   8   8   8   8   29   23   16   16   16   16   16   16   7   7   7   7   7   61   24   24   24   24   12   12   12   3   3   3   3   3   15   15   15   15   15   1   1   1   1   1   16   16   16   16   16   36   36   4   4   4   4   4   30   29   29   29   2   2   2   2   2   37   37   9   9   9   9   9   13   13   13   13   1   1   1   1   1   5   5   5   5   5   11   11   8   8   8   8   8   15   15   15   15   22   22   8   8   8   8   8   11   34   34   55   55   55   44   2   2   2   2   2   7   29   29   19   19   19   19   19   26   26   26   36   36   9   9   9   9   9   33   33   33   33   9   9   9   9   9   12   12   12   12   14   33   15   15   15   15   3   3   3   3   3   30   30   30   10   10   10   10   10   21   21   21   30   30   30   27   27   17   7   7   7   7   7}

do_execsql_test 1.12.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.12.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.12.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.12.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.12.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.12.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.12.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.12.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.12.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.12.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.12.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.12.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.12.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.12.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.12.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.12.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.12.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.12.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.12.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.13.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {74   99   99   99   33   89   89   96   96   96   68   68   68   91   91   91   99   99   99   97   78   78   97   97   97   67   93   93   93   84   77   23   93   93   93   65   47   86   86   86   91   91   91   85   85   85   59   59   56   56   91   91   91   90   90   55   89   89   89   47   56   56   56   56   56   75   75   89   98   98   98   81   94   94   94   78   78   78   53   63   63   87   87   87   84   84   84   72   61   73   95   95   95   65   96   98   98   98   74   74   74   65   73   73   73   87   87   87   41   20   31   31   31   95   95   95   79   88   88   88   34   49   49   90   90   96   96   96   75   77   77   77   44   85   85   85   74   74   70   70   59   39   39   47   80   90   90   90   58   58   72   72   72   72   93   93   93   81   81   81   37   37   37   14   62   91   91   91   91   91   34   36   99   99   99   95   95   69   58   52   84   84   84   84   84   39   44   58   58   58   38   83   83   83   82   82   17   7   {}   {}}

do_execsql_test 1.13.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {23   23   23   26   2   2   2   81   59   38   38   38   39   39   46   6   6   6   27   27   27   46   54   8   8   8   29   29   77   23   16   16   16   16   35   35   7   7   7   61   61   61   24   24   24   43   12   12   12   3   3   3   22   22   15   15   15   25   25   1   1   1   40   40   16   16   16   36   36   76   76   4   4   4   30   30   30   29   29   29   2   2   2   37   37   72   41   9   9   9   61   65   13   13   13   58   1   1   1   21   35   5   5   5   11   11   41   12   8   8   8   20   15   15   15   22   22   73   34   8   8   8   11   34   34   59   59   55   55   55   44   2   2   2   7   57   29   29   29   19   19   19   26   26   26   47   36   36   36   9   9   9   66   33   33   33   64   64   9   9   9   13   12   12   12   14   36   36   33   15   15   15   34   3   3   3   58   52   30   30   30   10   10   10   21   21   21   39   30   30   30   34   27   27   17   7   7   7   {}   {}}

do_execsql_test 1.13.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.13.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.13.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.13.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.13.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.13.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.13.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.13.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.13.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.13.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.13.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.13.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.13.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.13.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.13.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.13.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.13.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.13.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.13.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.14.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99}

do_execsql_test 1.14.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0}

do_execsql_test 1.14.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.14.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.14.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.14.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.14.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.14.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.14.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.14.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.14.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.14.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.14.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.14.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.14.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.14.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.14.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.14.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.14.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.14.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.14.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.15.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   83   83   83   83   83   83   83   83   83}

do_execsql_test 1.15.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {0   0   0   0   0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7}

do_execsql_test 1.15.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.15.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.15.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.15.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.15.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.15.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.15.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.15.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.15.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.15.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.15.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.15.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.15.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.15.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.15.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.15.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.15.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.15.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.15.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.16.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   83   83   83   83   83   83   83   83   83   82   82   17   7}

do_execsql_test 1.16.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {0   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7}

do_execsql_test 1.16.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.16.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.16.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.16.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.16.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.16.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.16.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.16.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.16.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.16.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.16.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.16.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.16.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.16.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.16.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.16.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.16.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.16.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.16.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

do_execsql_test 1.17.2.1 {
  SELECT max(b) OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   95   95   84   84   84   84   84   84   84   84   83   83   83   83   83   83   83   83   83   82   82   17   7   {}   {}   {}   {}}

do_execsql_test 1.17.2.2 {
  SELECT min(b) OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   {}   {}   {}   {}}

do_execsql_test 1.17.3.1 {
  SELECT row_number() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.17.3.2 {
  SELECT row_number() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.17.4.1 {
  SELECT dense_rank() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.17.4.2 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.17.4.3 {
  SELECT dense_rank() OVER ( ORDER BY b ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   3   3   3   4   4   5   6   7   8   8   8   9   9   9   10   10   10   11   12   12   13   13   13   14   14   15   16   16   16   17   17   17   18   19   20   21   21   22   22   23   23   23   24   25   26   26   26   27   27   28   29   29   29   30   30   30   31   31   32   33   33   33   33   33   34   34   34   34   35   35   36   36   36   36   37   37   38   38   39   39   39   40   41   41   41   42   43   43   44   44   45   45   46   46   46   46   47   48   49   50   51   52   53   53   54   54   54   55   56   56   56   56   57   57   57   57   58   59   59   60   60   61   62   63   63   63   64   65   66   67   68   69   69   69   70   70   70   71   71   71   71   71   72   72   72   73   74   74   75   75   76   77   77   78   78   78   79   80   81   81   81   81   82   82   82   83   84   84   85   86   86   86   87   87   87   88   88   88   88   88   89   89   89   90   91   91   91   92   92   92   93   93   94   94   95   95   95}

do_execsql_test 1.17.4.4 {
  SELECT dense_rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   5   6   7   8   9   9   10   10   10   1   1   2   2   3   3   4   4   5   5   5   6   7   7   8   8   8   9   9   9   9   9   1   1   1   2   2   2   3   3   4   5   6   7   7   8   8   8   9   1   1   2   2   3   3   3   4   4   4   4   4   5   5   6   7   8   8   8   9   10   10   10   1   2   3   4   4   4   4   5   5   6   7   8   8   8   8   8   9   9   9   9   10   1   2   2   2   3   4   4   5   5   6   6   6   7   7   7   8   8   8   9   9   9   1   2   2   2   3   3   3   4   4   4   4   5   5   6   6   6   7   8   9   10   10   10   1   1   1   2   3   3   4   4   5   5   5   5   6   7   8   8   9   9   10   10   1   1   1   2   3   3   4   4   4   4   5   6   6   7   8   8   1   1   1   2   3   3   3   4   4   4   5   6   6   6   6   7   8   9   9   9   10   10   10}

do_execsql_test 1.17.4.5 {
  SELECT dense_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   6   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   7   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   9   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10   10}

do_execsql_test 1.17.4.6 {
  SELECT dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5}

do_execsql_test 1.17.5.1 {
  SELECT rank() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {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   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200}

do_execsql_test 1.17.5.2 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23}

do_execsql_test 1.17.5.3 {
  SELECT rank() OVER ( ORDER BY b ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   2   4   4   4   7   7   9   10   11   12   12   12   15   15   15   18   18   18   21   22   22   24   24   24   27   27   29   30   30   30   33   33   33   36   37   38   39   39   41   41   43   43   43   46   47   48   48   48   51   51   53   54   54   54   57   57   57   60   60   62   63   63   63   63   63   68   68   68   68   72   72   74   74   74   74   78   78   80   80   82   82   82   85   86   86   86   89   90   90   92   92   94   94   96   96   96   96   100   101   102   103   104   105   106   106   108   108   108   111   112   112   112   112   116   116   116   116   120   121   121   123   123   125   126   127   127   127   130   131   132   133   134   135   135   135   138   138   138   141   141   141   141   141   146   146   146   149   150   150   152   152   154   155   155   157   157   157   160   161   162   162   162   162   166   166   166   169   170   170   172   173   173   173   176   176   176   179   179   179   179   179   184   184   184   187   188   188   188   191   191   191   194   194   196   196   198   198   198}

do_execsql_test 1.17.5.4 {
  SELECT rank() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   2   3   4   4   4   7   8   9   10   11   11   13   13   13   1   1   3   3   5   5   7   7   9   9   9   12   13   13   15   15   15   18   18   18   18   18   1   1   1   4   4   4   7   7   9   10   11   12   12   14   14   14   17   1   1   3   3   5   5   5   8   8   8   8   8   13   13   15   16   17   17   17   20   21   21   21   1   2   3   4   4   4   4   8   8   10   11   12   12   12   12   12   17   17   17   17   21   1   2   2   2   5   6   6   8   8   10   10   10   13   13   13   16   16   16   19   19   19   1   2   2   2   5   5   5   8   8   8   8   12   12   14   14   14   17   18   19   20   20   20   1   1   1   4   5   5   7   7   9   9   9   9   13   14   15   15   17   17   19   19   1   1   1   4   5   5   7   7   7   7   11   12   12   14   15   15   1   1   1   4   5   5   5   8   8   8   11   12   12   12   12   16   17   18   18   18   21   21   21}

do_execsql_test 1.17.5.5 {
  SELECT rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   38   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   55   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   78   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   99   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   120   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   142   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   162   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178   178}

do_execsql_test 1.17.5.6 {
  SELECT rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2
} {1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   16   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   33   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   54   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   76   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   23   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   46   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   67   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87   87}

do_execsql_test 1.17.6.1 {
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

do_execsql_test 1.17.7.1 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   3   3   4   4   5   5   6   6   7   7   8   8   9   9   10   10   11   11   12   12   13   13   14   14   15   15   16   16   17   17   18   18   19   19   20   20   21   21   22   22   23   23   24   24   25   25   26   26   27   27   28   28   29   29   30   30   31   31   32   32   33   33   34   34   35   35   36   36   37   37   38   38   39   39   40   40   41   41   42   42   43   43   44   44   45   45   46   46   47   47   48   48   49   49   50   50   51   51   52   52   53   53   54   54   55   55   56   56   57   57   58   58   59   59   60   60   61   61   62   62   63   63   64   64   65   65   66   66   67   67   68   68   69   69   70   70   71   71   72   72   73   73   74   74   75   75   76   76   77   77   78   78   79   79   80   80   81   81   82   82   83   83   84   84   85   85   86   86   87   87   88   88   89   89   90   90   91   91   92   92   93   93   94   94   95   95   96   96   97   97   98   98   99   99   100}

do_execsql_test 1.17.7.3 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   1   1   2   2   2   3   3   4   5   5   6   6   6   7   7   7   9   9   9   10   11   11   12   12   12   13   13   14   15   15   15   16   16   16   18   18   19   19   19   20   20   21   21   21   23   23   24   24   24   25   25   26   27   27   27   28   28   28   30   30   31   31   31   31   31   31   34   34   34   34   36   36   37   37   37   37   39   39   40   40   41   41   41   42   43   43   43   44   45   45   46   46   47   47   48   48   48   48   50   50   51   51   52   52   53   53   54   54   54   55   56   56   56   56   58   58   58   58   60   60   60   61   61   62   63   63   63   63   65   65   66   66   67   67   67   67   69   69   69   70   70   70   70   70   73   73   73   74   75   75   76   76   77   77   77   78   78   78   80   80   81   81   81   81   83   83   83   84   85   85   86   86   86   86   88   88   88   89   89   89   89   89   92   92   92   93   94   94   94   95   95   95   97   97   98   98   99   99   99}

do_execsql_test 1.17.7.5 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   8   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   19   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   27   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   39   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   49   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   60   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   71   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   81   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89   89}

do_execsql_test 1.17.7.6 {
  SELECT CAST( round( 100 * 
      percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING )
  ) AS integer) FROM t2
} {0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   17   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   36   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   59   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   83   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   20   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   42   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   61   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80   80}

finish_test