/ Check-in [3f093f60]
Login

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

Overview
Comment:Add implementation of window function ntile().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | exp-window-functions
Files: files | file ages | folders
SHA3-256:3f093f608c6cc193aac77e7eafa8006c27a7776682d9d7b6e743710dff41ae42
User & Date: dan 2018-06-04 18:55:11
Context
2018-06-05
16:16
Add implementation of last_value() window function. check-in: 2493ce1a user: dan tags: exp-window-functions
2018-06-04
18:55
Add implementation of window function ntile(). check-in: 3f093f60 user: dan tags: exp-window-functions
08:28
Merge latest trunk changes into this branch. check-in: 83d6416a user: dan tags: exp-window-functions
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/window.c.

175
176
177
178
179
180
181































































182
183
184
185
186
187
188
...
207
208
209
210
211
212
213

214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
...
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572



573






574
575
576
577
578
579
580
...
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
  struct CallCount *p;
  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ){
    double r = (double)(p->nStep) / (double)(p->nTotal);
    sqlite3_result_double(pCtx, r);
  }
}
































































static void nth_valueStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
................................................................................
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(cume_dist, 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;
    }
................................................................................
  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->csrApp ){
      if( bInverse==0 ){
        sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1);
        sqlite3VdbeAddOp2(v, OP_SCopy, regArg, pWin->regApp);
................................................................................
    sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regEnd);
  }

  /* Initialize the accumulator register for each window function to NULL */
  nArg = 0;
  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
    nArg = MAX(nArg, pWin->nArg);
  }
  regArg = pParse->nMem+1;
  pParse->nMem += nArg;

  sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblFlushDone);
  sqlite3VdbeAddOp2(v, OP_Rewind, csrStart, lblFlushDone);
  sqlite3VdbeChangeP5(v, 1);







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







 







>








|







 







<
<
<
|





>
>
>
|
>
>
>
>
>
>







 







|







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
...
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
...
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
...
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
  struct CallCount *p;
  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ){
    double r = (double)(p->nStep) / (double)(p->nTotal);
    sqlite3_result_double(pCtx, r);
  }
}

struct NtileCtx {
  i64 nTotal;                     /* Total rows in partition */
  i64 nParam;                     /* Parameter passed to ntile(N) */
  i64 iRow;                       /* Current row */
};

/*
** Implementation of ntile(). This assumes that the window frame has
** been coerced to:
**
**   ROWS UNBOUNDED PRECEDING AND CURRENT ROW
**
*/
static void ntileStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
  struct NtileCtx *p;
  assert( nArg==2 );
  p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ){
    if( p->nTotal==0 ){
      p->nParam = sqlite3_value_int64(apArg[0]);
      p->nTotal = sqlite3_value_int64(apArg[1]);
      if( p->nParam<=0 ){
        sqlite3_result_error(
            pCtx, "argument of ntile must be a positive integer", -1
        );
      }
    }
    p->iRow++;
  }
}
static void ntileInverseFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
static void ntileValueFunc(sqlite3_context *pCtx){
  struct NtileCtx *p;
  p = (struct NtileCtx*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p && p->nParam>0 ){
    int nSize = (p->nTotal / p->nParam);
    if( nSize==0 ){
      sqlite3_result_int64(pCtx, p->iRow);
    }else{
      i64 nLarge = p->nTotal - p->nParam*nSize;
      i64 iSmall = nLarge*(nSize+1);
      i64 iRow = p->iRow-1;

      assert( (nLarge*(nSize+1) + (p->nParam-nLarge)*nSize)==p->nTotal );

      if( iRow<iSmall ){
        sqlite3_result_int64(pCtx, 1 + iRow/(nSize+1));
      }else{
        sqlite3_result_int64(pCtx, 1 + nLarge + (iRow-iSmall)/nSize);
      }
    }
  }
}

static void nth_valueStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
................................................................................
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(cume_dist, 0, SQLITE_FUNC_WINDOW_SIZE),
    WINDOWFUNC(ntile, 1, 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 || pFunc->xSFunc==ntileStepFunc ){
      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;
    }
................................................................................
  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( csr>=0 ){
      int i;
      for(i=0; i<pWin->nArg; i++){
        sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i);
      }
      regArg = reg;
      if( flags & SQLITE_FUNC_WINDOW_SIZE ){
        if( nArg==0 ){
          regArg = regPartSize;
        }else{
          sqlite3VdbeAddOp2(v, OP_SCopy, regPartSize, reg+nArg);
        }
        nArg++;
      }
    }else{
      assert( !(flags & SQLITE_FUNC_WINDOW_SIZE) );
      regArg = reg + pWin->iArgCol;
    }

    if( pWin->csrApp ){
      if( bInverse==0 ){
        sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1);
        sqlite3VdbeAddOp2(v, OP_SCopy, regArg, pWin->regApp);
................................................................................
    sqlite3VdbeAddOp3(v, OP_Subtract, regStart, regEnd, regEnd);
  }

  /* Initialize the accumulator register for each window function to NULL */
  nArg = 0;
  for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
    sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regAccum);
    nArg = MAX(nArg, pWin->nArg+1);
  }
  regArg = pParse->nMem+1;
  pParse->nMem += nArg;

  sqlite3VdbeAddOp2(v, OP_Rewind, pMWin->iEphCsr, lblFlushDone);
  sqlite3VdbeAddOp2(v, OP_Rewind, csrStart, lblFlushDone);
  sqlite3VdbeChangeP5(v, 1);

Changes to test/window1.test.

176
177
178
179
180
181
182














183
184
185
  5 2 6.5
  4 3 6.5.4
  3 4 6.5.4.3
  2 5 6.5.4.3.2
  1 6 6.5.4.3.2.1
  0 7 6.5.4.3.2.1.0
}
















finish_test







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



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
  5 2 6.5
  4 3 6.5.4
  3 4 6.5.4.3
  2 5 6.5.4.3.2
  1 6 6.5.4.3.2.1
  0 7 6.5.4.3.2.1.0
}

do_catchsql_test 5.1 {
  SELECT ntile(0) OVER (ORDER BY a) FROM t2;
} {1 {argument of ntile must be a positive integer}}
do_catchsql_test 5.2 {
  SELECT ntile(-1) OVER (ORDER BY a) FROM t2;
} {1 {argument of ntile must be a positive integer}}
do_catchsql_test 5.3 {
  SELECT ntile('zbc') OVER (ORDER BY a) FROM t2;
} {1 {argument of ntile must be a positive integer}}
do_execsql_test 5.4 {
  CREATE TABLE t4(a, b);
  SELECT ntile(1) OVER (ORDER BY a) FROM t4;
} {}


finish_test

Changes to test/window3.tcl.

163
164
165
166
167
168
169


















170
171
172
173
174
  execsql_float_test 1.$tn.8.5 "
    SELECT cume_dist() OVER ( ORDER BY b%10 $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.6 "
    SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
  "



















}


finish_test








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



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
  execsql_float_test 1.$tn.8.5 "
    SELECT cume_dist() OVER ( ORDER BY b%10 $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.6 "
    SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
  "

  execsql_float_test 1.$tn.8.1 "
    SELECT ntile(100) OVER ( ORDER BY a $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.2 "
    SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.3 "
    SELECT ntile(102) OVER ( ORDER BY b,a $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.4 "
    SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.5 "
    SELECT ntile(104) OVER ( ORDER BY b%10,a $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.6 "
    SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 $window) FROM t2
  "

}

finish_test

Changes to test/window3.test.

175
176
177
178
179
180
181
















182
183
184
185
186









































































187
188
189
190
191
192
193
...
303
304
305
306
307
308
309
















310
311
312
313
314









































































315
316
317
318
319
320
321
...
431
432
433
434
435
436
437
















438
439
440
441
442









































































443
444
445
446
447
448
449
...
559
560
561
562
563
564
565
















566
567
568
569
570









































































571
572
573
574
575
576
577
...
687
688
689
690
691
692
693
















694
695
696
697
698









































































699
700
701
702
703
704
705
...
815
816
817
818
819
820
821
















822
823
824
825
826









































































827
828
829
830
831
832
833
...
943
944
945
946
947
948
949
















950
951
952
953
954









































































955
956
957
958
959
960
961
....
1071
1072
1073
1074
1075
1076
1077
















1078
1079
1080
1081
1082









































































1083
1084
1085
1086
1087
1088
1089
....
1199
1200
1201
1202
1203
1204
1205
















1206
1207
1208
1209
1210









































































1211
1212
1213
1214
1215
1216
1217
....
1327
1328
1329
1330
1331
1332
1333
















1334
1335
1336
1337
1338









































































1339
1340
1341
1342
1343
1344
1345
....
1455
1456
1457
1458
1459
1460
1461
















1462
1463
1464
1465
1466









































































1467
1468
1469
1470
1471
1472
1473
....
1583
1584
1585
1586
1587
1588
1589
















1590
1591
1592
1593
1594









































































1595
1596
1597
1598
1599
1600
1601
....
1711
1712
1713
1714
1715
1716
1717
















1718
1719
1720
1721
1722









































































1723
1724
1725
1726
1727
1728
1729
....
1839
1840
1841
1842
1843
1844
1845
















1846
1847
1848
1849
1850









































































1851
1852
1853
1854
1855
1856
1857
....
1967
1968
1969
1970
1971
1972
1973
















1974
1975
1976
1977
1978









































































1979
1980
1981
1982
1983
1984
1985
....
2095
2096
2097
2098
2099
2100
2101
















2102
2103
2104
2105
2106









































































2107
2108
2109
2110
2111
2112
2113
....
2223
2224
2225
2226
2227
2228
2229
















2230
2231
2232
2233
2234

2235








































































2236
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.1.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.2.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.3.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.4.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.5.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.6.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.7.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.8.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.9.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.10.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.11.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.12.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.13.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.14.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.15.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.16.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.17.8.1 {
  set myres {}
















  foreach r [db eval {SELECT b, cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.01 1.00 0.01 1.00 0.01 2.00 0.03 2.00 0.03 2.00 0.03 3.00 0.04 3.00 0.04 4.00 0.04 5.00 0.05 6.00 0.06 7.00 0.07 7.00 0.07 7.00 0.07 8.00 0.09 8.00 0.09 8.00 0.09 9.00 0.10 9.00 0.10 9.00 0.10 10.00 0.10 11.00 0.12 11.00 0.12 12.00 0.13 12.00 0.13 12.00 0.13 13.00 0.14 13.00 0.14 14.00 0.14 15.00 0.16 15.00 0.16 15.00 0.16 16.00 0.17 16.00 0.17 16.00 0.17 17.00 0.18 19.00 0.18 20.00 0.19 21.00 0.20 21.00 0.20 22.00 0.21 22.00 0.21 23.00 0.23 23.00 0.23 23.00 0.23 24.00 0.23 25.00 0.23 26.00 0.25 26.00 0.25 26.00 0.25 27.00 0.26 27.00 0.26 28.00 0.27 29.00 0.28 29.00 0.28 29.00 0.28 30.00 0.29 30.00 0.29 30.00 0.29 31.00 0.30 31.00 0.30 32.00 0.31 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 33.00 0.34 34.00 0.35 34.00 0.35 34.00 0.35 34.00 0.35 35.00 0.36 35.00 0.36 36.00 0.39 36.00 0.39 36.00 0.39 36.00 0.39 37.00 0.40 37.00 0.40 38.00 0.41 38.00 0.41 39.00 0.42 39.00 0.42 39.00 0.42 40.00 0.42 41.00 0.44 41.00 0.44 41.00 0.44 42.00 0.45 43.00 0.46 43.00 0.46 44.00 0.47 44.00 0.47 46.00 0.47 46.00 0.47 47.00 0.49 47.00 0.49 47.00 0.49 47.00 0.49 49.00 0.50 50.00 0.51 51.00 0.51 52.00 0.52 53.00 0.52 54.00 0.53 55.00 0.54 55.00 0.54 56.00 0.55 56.00 0.55 56.00 0.55 57.00 0.56 58.00 0.57 58.00 0.57 58.00 0.57 58.00 0.57 59.00 0.59 59.00 0.59 59.00 0.59 59.00 0.59 60.00 0.60 61.00 0.61 61.00 0.61 62.00 0.62 62.00 0.62 63.00 0.62 64.00 0.63 65.00 0.65 65.00 0.65 65.00 0.65 66.00 0.65 67.00 0.66 68.00 0.66 69.00 0.67 70.00 0.67 72.00 0.69 72.00 0.69 72.00 0.69 73.00 0.70 73.00 0.70 73.00 0.70 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 74.00 0.72 75.00 0.74 75.00 0.74 75.00 0.74 76.00 0.74 77.00 0.76 77.00 0.76 78.00 0.77 78.00 0.77 79.00 0.77 80.00 0.78 80.00 0.78 81.00 0.80 81.00 0.80 81.00 0.80 82.00 0.80 83.00 0.81 84.00 0.82 84.00 0.82 84.00 0.82 84.00 0.82 85.00 0.84 85.00 0.84 85.00 0.84 86.00 0.84 87.00 0.85 87.00 0.85 88.00 0.86 89.00 0.88 89.00 0.88 89.00 0.88 90.00 0.89 90.00 0.89 90.00 0.89 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 91.00 0.92 93.00 0.93 93.00 0.93 93.00 0.93 94.00 0.94 95.00 0.95 95.00 0.95 95.00 0.95 96.00 0.96 96.00 0.96 96.00 0.96 97.00 0.97 97.00 0.97 98.00 0.98 98.00 0.98 99.00 1.00 99.00 1.00 99.00 1.00}










































































finish_test







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







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



<
>

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

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
...
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
...
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
...
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
....
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
....
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
....
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
....
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713

1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
....
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929

1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
....
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145

2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
....
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361

2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
....
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577

2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
....
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793

2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
....
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009

3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
....
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225

3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
....
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441

3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
....
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657

3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.1.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.1.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.1.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.1.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.1.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.1.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.1.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.1.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.1.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.1.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.1.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.1.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.2.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.2.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.2.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.2.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.2.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.2.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.2.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.2.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.2.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.2.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.2.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.2.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.3.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.3.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.3.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.3.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.3.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.3.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.3.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.3.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.3.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.3.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.3.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.3.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND CURRENT ROW) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.4.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.4.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.4.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.4.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.4.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.4.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.4.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.4.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.4.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.4.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.4.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.4.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 RANGE BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.5.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.5.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.5.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.5.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.5.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.5.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.5.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.5.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.5.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.5.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.5.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.5.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 PRECEDING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.6.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.6.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.6.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.6.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.6.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.6.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.6.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.6.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.6.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.6.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.6.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.6.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 PRECEDING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.7.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.7.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.7.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.7.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.7.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.7.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.7.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.7.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.7.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.7.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.7.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.7.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.8.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.8.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.8.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.8.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.8.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.8.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.8.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.8.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.8.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.8.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.8.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.8.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND CURRENT ROW) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.9.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.9.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.9.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.9.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.9.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.9.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.9.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.9.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.9.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.9.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.9.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW         AND CURRENT ROW ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.9.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND CURRENT ROW) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.10.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.10.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.10.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.10.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.10.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.10.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.10.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.10.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.10.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.10.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.10.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.10.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND 4 FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.11.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.11.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.11.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.11.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.11.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.11.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.11.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.11.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.11.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.11.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.11.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.11.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND 2 FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.12.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.12.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.12.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.12.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.12.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.12.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.12.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.12.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.12.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.12.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.12.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.12.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND 4 FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.13.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.13.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.13.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.13.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.13.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.13.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.13.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.13.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.13.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.13.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.13.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.13.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 2 FOLLOWING    AND 4 FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.14.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.14.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.14.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.14.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.14.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.14.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.14.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.14.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.14.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.14.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.14.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.14.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.15.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.15.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.15.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.15.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.15.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.15.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.15.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.15.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.15.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.15.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.15.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.15.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 PRECEDING    AND UNBOUNDED FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.16.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.16.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.16.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.16.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.16.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.16.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.16.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.16.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.16.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.16.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.16.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.16.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

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
................................................................................
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.17 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.36 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.83 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.42 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80 0.80}

do_test 1.17.8.1 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.01 0.01 0.01 0.02 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.06 0.07 0.07 0.07 0.08 0.09 0.09 0.10 0.10 0.10 0.11 0.12 0.12 0.12 0.13 0.14 0.14 0.14 0.15 0.15 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.20 0.21 0.21 0.22 0.23 0.23 0.23 0.24 0.24 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.47 0.48 0.48 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.55 0.55 0.56 0.56 0.56 0.57 0.57 0.58 0.58 0.59 0.59 0.60 0.60 0.61 0.61 0.62 0.62 0.63 0.64 0.64 0.65 0.65 0.66 0.66 0.67 0.67 0.68 0.68 0.69 0.69 0.69 0.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 0.76 0.76 0.77 0.77 0.78 0.78 0.79 0.79 0.80 0.80 0.81 0.81 0.81 0.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 0.88 0.88 0.89 0.89 0.90 0.90 0.91 0.91 0.92 0.92 0.93 0.93 0.94 0.94 0.94 0.95 0.95 0.96 0.96 0.97 0.97 0.98 0.98 0.99 0.99 1.00}

do_test 1.17.8.2 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.27 0.33 0.40 0.47 0.53 0.60 0.67 0.73 0.80 0.87 0.93 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.06 0.12 0.18 0.24 0.29 0.35 0.41 0.47 0.53 0.59 0.65 0.71 0.76 0.82 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.10 0.14 0.19 0.24 0.29 0.33 0.38 0.43 0.48 0.52 0.57 0.62 0.67 0.71 0.76 0.81 0.86 0.90 0.95 1.00 0.05 0.09 0.14 0.18 0.23 0.27 0.32 0.36 0.41 0.45 0.50 0.55 0.59 0.64 0.68 0.73 0.77 0.82 0.86 0.91 0.95 1.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95 1.00 0.06 0.12 0.19 0.25 0.31 0.38 0.44 0.50 0.56 0.62 0.69 0.75 0.81 0.88 0.94 1.00 0.04 0.09 0.13 0.17 0.22 0.26 0.30 0.35 0.39 0.43 0.48 0.52 0.57 0.61 0.65 0.70 0.74 0.78 0.83 0.87 0.91 0.96 1.00}

do_test 1.17.8.3 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres

} {0.01 0.01 0.01 0.03 0.03 0.03 0.04 0.04 0.04 0.05 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.10 0.10 0.10 0.12 0.12 0.13 0.13 0.13 0.14 0.14 0.14 0.16 0.16 0.16 0.17 0.17 0.17 0.18 0.18 0.19 0.20 0.20 0.21 0.21 0.23 0.23 0.23 0.23 0.23 0.25 0.25 0.25 0.26 0.26 0.27 0.28 0.28 0.28 0.29 0.29 0.29 0.30 0.30 0.31 0.34 0.34 0.34 0.34 0.34 0.35 0.35 0.35 0.35 0.36 0.36 0.39 0.39 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.42 0.42 0.44 0.44 0.44 0.45 0.46 0.46 0.47 0.47 0.47 0.47 0.49 0.49 0.49 0.49 0.50 0.51 0.51 0.52 0.52 0.53 0.54 0.54 0.55 0.55 0.55 0.56 0.57 0.57 0.57 0.57 0.59 0.59 0.59 0.59 0.60 0.61 0.61 0.62 0.62 0.62 0.63 0.65 0.65 0.65 0.65 0.66 0.66 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.72 0.72 0.72 0.72 0.72 0.74 0.74 0.74 0.74 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.80 0.80 0.80 0.80 0.81 0.82 0.82 0.82 0.82 0.84 0.84 0.84 0.84 0.85 0.85 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.92 0.92 0.92 0.92 0.92 0.93 0.93 0.93 0.94 0.95 0.95 0.95 0.96 0.96 0.96 0.97 0.97 0.98 0.98 1.00 1.00 1.00}

do_test 1.17.8.4 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.13 0.20 0.40 0.40 0.40 0.47 0.53 0.60 0.67 0.80 0.80 1.00 1.00 1.00 0.09 0.09 0.18 0.18 0.27 0.27 0.36 0.36 0.50 0.50 0.50 0.55 0.64 0.64 0.77 0.77 0.77 1.00 1.00 1.00 1.00 1.00 0.18 0.18 0.18 0.35 0.35 0.35 0.47 0.47 0.53 0.59 0.65 0.76 0.76 0.94 0.94 0.94 1.00 0.09 0.09 0.17 0.17 0.30 0.30 0.30 0.52 0.52 0.52 0.52 0.52 0.61 0.61 0.65 0.70 0.83 0.83 0.83 0.87 1.00 1.00 1.00 0.05 0.10 0.14 0.33 0.33 0.33 0.33 0.43 0.43 0.48 0.52 0.76 0.76 0.76 0.76 0.76 0.95 0.95 0.95 0.95 1.00 0.05 0.19 0.19 0.19 0.24 0.33 0.33 0.43 0.43 0.57 0.57 0.57 0.71 0.71 0.71 0.86 0.86 0.86 1.00 1.00 1.00 0.05 0.18 0.18 0.18 0.32 0.32 0.32 0.50 0.50 0.50 0.50 0.59 0.59 0.73 0.73 0.73 0.77 0.82 0.86 1.00 1.00 1.00 0.15 0.15 0.15 0.20 0.30 0.30 0.40 0.40 0.60 0.60 0.60 0.60 0.65 0.70 0.80 0.80 0.90 0.90 1.00 1.00 0.19 0.19 0.19 0.25 0.38 0.38 0.62 0.62 0.62 0.62 0.69 0.81 0.81 0.88 1.00 1.00 0.13 0.13 0.13 0.17 0.30 0.30 0.30 0.43 0.43 0.43 0.48 0.65 0.65 0.65 0.65 0.70 0.74 0.87 0.87 0.87 1.00 1.00 1.00}

do_test 1.17.8.5 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.07 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.18 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.27 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.39 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.49 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.59 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.70 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.81 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 0.89 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.17.8.6 {
  set myres {}
  foreach r [db eval {SELECT cume_dist() OVER ( PARTITION BY b%2 ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.16 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.35 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.58 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 0.82 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.41 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.61 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 0.79 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

do_test 1.17.8.1 {
  set myres {}
  foreach r [db eval {SELECT ntile(100) OVER ( ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 99.00 100.00 100.00}

do_test 1.17.8.2 {
  set myres {}
  foreach r [db eval {SELECT ntile(101) OVER ( PARTITION BY b%10 ORDER BY a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.17.8.3 {
  set myres {}
  foreach r [db eval {SELECT ntile(102) OVER ( ORDER BY b,a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 97.00 98.00 98.00 99.00 100.00 101.00 102.00}

do_test 1.17.8.4 {
  set myres {}
  foreach r [db eval {SELECT ntile(103) OVER ( PARTITION BY b%10 ORDER BY b,a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00 21.00 22.00 23.00}

do_test 1.17.8.5 {
  set myres {}
  foreach r [db eval {SELECT ntile(104) OVER ( ORDER BY b%10,a ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING ) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 2.00 2.00 3.00 3.00 4.00 4.00 5.00 5.00 6.00 6.00 7.00 7.00 8.00 8.00 9.00 9.00 10.00 10.00 11.00 11.00 12.00 12.00 13.00 13.00 14.00 14.00 15.00 15.00 16.00 16.00 17.00 17.00 18.00 18.00 19.00 19.00 20.00 20.00 21.00 21.00 22.00 22.00 23.00 23.00 24.00 24.00 25.00 25.00 26.00 26.00 27.00 27.00 28.00 28.00 29.00 29.00 30.00 30.00 31.00 31.00 32.00 32.00 33.00 33.00 34.00 34.00 35.00 35.00 36.00 36.00 37.00 37.00 38.00 38.00 39.00 39.00 40.00 40.00 41.00 41.00 42.00 42.00 43.00 43.00 44.00 44.00 45.00 45.00 46.00 46.00 47.00 47.00 48.00 48.00 49.00 49.00 50.00 50.00 51.00 51.00 52.00 52.00 53.00 53.00 54.00 54.00 55.00 55.00 56.00 56.00 57.00 57.00 58.00 58.00 59.00 59.00 60.00 60.00 61.00 61.00 62.00 62.00 63.00 63.00 64.00 64.00 65.00 65.00 66.00 66.00 67.00 67.00 68.00 68.00 69.00 69.00 70.00 70.00 71.00 71.00 72.00 72.00 73.00 73.00 74.00 74.00 75.00 75.00 76.00 76.00 77.00 77.00 78.00 78.00 79.00 79.00 80.00 80.00 81.00 81.00 82.00 82.00 83.00 83.00 84.00 84.00 85.00 85.00 86.00 86.00 87.00 87.00 88.00 88.00 89.00 89.00 90.00 90.00 91.00 91.00 92.00 92.00 93.00 93.00 94.00 94.00 95.00 95.00 96.00 96.00 97.00 98.00 99.00 100.00 101.00 102.00 103.00 104.00}

do_test 1.17.8.6 {
  set myres {}
  foreach r [db eval {SELECT ntile(105) OVER (PARTITION BY b%2,a ORDER BY b%10 ROWS BETWEEN 4 FOLLOWING    AND UNBOUNDED FOLLOWING) FROM t2}] {
    lappend myres [format %.2f [set r]]
  }
  set myres
} {1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00}

finish_test

Added test/window4.tcl.





























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# 2018 May 19
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    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.
#
#***********************************************************************
#

source [file join [file dirname $argv0] pg_common.tcl]

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

start_test window4 "2018 June 04"

execsql_test 1.0 {
  DROP TABLE IF EXISTS t3;
  CREATE TABLE t3(a TEXT PRIMARY KEY);
  INSERT INTO t3 VALUES('a'), ('b'), ('c'), ('d'), ('e');
  INSERT INTO t3 VALUES('f'), ('g'), ('h'), ('i'), ('j');
}

for {set i 1} {$i < 20} {incr i} {
  execsql_test 1.$i "SELECT a, ntile($i) OVER (ORDER BY a) FROM t3"
}

finish_test

Added test/window4.test.



















































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
# 2018 June 04
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    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.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#

####################################################
# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
####################################################

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix window4

do_execsql_test 1.0 {
  DROP TABLE IF EXISTS t3;
  CREATE TABLE t3(a TEXT PRIMARY KEY);
  INSERT INTO t3 VALUES('a'), ('b'), ('c'), ('d'), ('e');
  INSERT INTO t3 VALUES('f'), ('g'), ('h'), ('i'), ('j');
} {}

do_execsql_test 1.1 {
  SELECT a, ntile(1) OVER (ORDER BY a) FROM t3
} {a 1   b 1   c 1   d 1   e 1   f 1   g 1   h 1   i 1   j 1}

do_execsql_test 1.2 {
  SELECT a, ntile(2) OVER (ORDER BY a) FROM t3
} {a 1   b 1   c 1   d 1   e 1   f 2   g 2   h 2   i 2   j 2}

do_execsql_test 1.3 {
  SELECT a, ntile(3) OVER (ORDER BY a) FROM t3
} {a 1   b 1   c 1   d 1   e 2   f 2   g 2   h 3   i 3   j 3}

do_execsql_test 1.4 {
  SELECT a, ntile(4) OVER (ORDER BY a) FROM t3
} {a 1   b 1   c 1   d 2   e 2   f 2   g 3   h 3   i 4   j 4}

do_execsql_test 1.5 {
  SELECT a, ntile(5) OVER (ORDER BY a) FROM t3
} {a 1   b 1   c 2   d 2   e 3   f 3   g 4   h 4   i 5   j 5}

do_execsql_test 1.6 {
  SELECT a, ntile(6) OVER (ORDER BY a) FROM t3
} {a 1   b 1   c 2   d 2   e 3   f 3   g 4   h 4   i 5   j 6}

do_execsql_test 1.7 {
  SELECT a, ntile(7) OVER (ORDER BY a) FROM t3
} {a 1   b 1   c 2   d 2   e 3   f 3   g 4   h 5   i 6   j 7}

do_execsql_test 1.8 {
  SELECT a, ntile(8) OVER (ORDER BY a) FROM t3
} {a 1   b 1   c 2   d 2   e 3   f 4   g 5   h 6   i 7   j 8}

do_execsql_test 1.9 {
  SELECT a, ntile(9) OVER (ORDER BY a) FROM t3
} {a 1   b 1   c 2   d 3   e 4   f 5   g 6   h 7   i 8   j 9}

do_execsql_test 1.10 {
  SELECT a, ntile(10) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

do_execsql_test 1.11 {
  SELECT a, ntile(11) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

do_execsql_test 1.12 {
  SELECT a, ntile(12) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

do_execsql_test 1.13 {
  SELECT a, ntile(13) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

do_execsql_test 1.14 {
  SELECT a, ntile(14) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

do_execsql_test 1.15 {
  SELECT a, ntile(15) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

do_execsql_test 1.16 {
  SELECT a, ntile(16) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

do_execsql_test 1.17 {
  SELECT a, ntile(17) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

do_execsql_test 1.18 {
  SELECT a, ntile(18) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

do_execsql_test 1.19 {
  SELECT a, ntile(19) OVER (ORDER BY a) FROM t3
} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}

finish_test