/ Check-in [76543f7d]
Login

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

Overview
Comment:Add support for window function cume_dist(). Improve tests for percent_rank().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | exp-window-functions
Files: files | file ages | folders
SHA3-256:76543f7dd3a2310f6e81a1bae17db9bb5d2cf10c1b87ed3f8394b3e75576078b
User & Date: dan 2018-06-04 08:22:09
Context
2018-06-04
08:28
Merge latest trunk changes into this branch. check-in: 83d6416a user: dan tags: exp-window-functions
08:22
Add support for window function cume_dist(). Improve tests for percent_rank(). check-in: 76543f7d user: dan tags: exp-window-functions
2018-06-02
21:04
Add support for window functions row_number(), rank(), dense_rank() and percent_rank(). check-in: 91c1cb7a user: dan tags: exp-window-functions
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/window.c.

144
145
146
147
148
149
150































151
152
153
154
155
156
157
...
175
176
177
178
179
180
181

182
183
184
185
186
187
188
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
      sqlite3_result_double(pCtx, r);
    }else{
      sqlite3_result_double(pCtx, 100.0);
    }
    p->nValue = 0;
  }
}
































static void nth_valueStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
................................................................................
*/
void sqlite3WindowFunctions(void){
  static FuncDef aWindowFuncs[] = {
    WINDOWFUNC(row_number, 0, 0),
    WINDOWFUNC(dense_rank, 0, 0),
    WINDOWFUNC(rank, 0, 0),
    WINDOWFUNC(percent_rank, 0, SQLITE_FUNC_WINDOW_SIZE),

    WINDOWFUNC(nth_value, 2, 0),
  };
  sqlite3InsertBuiltinFuncs(aWindowFuncs, ArraySize(aWindowFuncs));
}

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

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







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







 







>







 







|







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
...
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
...
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
      sqlite3_result_double(pCtx, r);
    }else{
      sqlite3_result_double(pCtx, 100.0);
    }
    p->nValue = 0;
  }
}

static void cume_distStepFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
  struct CallCount *p;
  assert( nArg==1 );

  p = (struct CallCount*)sqlite3_aggregate_context(pCtx, sizeof(*p));
  if( p ){
    if( p->nTotal==0 ){
      p->nTotal = sqlite3_value_int64(apArg[0]);
    }
    p->nStep++;
  }
}
static void cume_distInverseFunc(
  sqlite3_context *pCtx, 
  int nArg,
  sqlite3_value **apArg
){
}
static void cume_distValueFunc(sqlite3_context *pCtx){
  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 ){
................................................................................
      pWin->pStart = pWin->pEnd = 0;
      pWin->eType = TK_ROWS;
      pWin->eStart = TK_UNBOUNDED;
      pWin->eEnd = TK_CURRENT;
    }

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

Changes to test/pg_common.tcl.

61
62
63
64
65
66
67



















68
69
70
71
72
73
74
proc execsql_test {tn sql} {
  set res [execsql $sql]
  puts $::fd "do_execsql_test $tn {"
  puts $::fd "  [string trim $sql]"
  puts $::fd "} {$res}"
  puts $::fd ""
}




















proc start_test {name date} {
  set dir [file dirname $::argv0]
  set output [file join $dir $name.test]
  set ::fd [open $output w]
puts $::fd [string trimleft "
# $date







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







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
proc execsql_test {tn sql} {
  set res [execsql $sql]
  puts $::fd "do_execsql_test $tn {"
  puts $::fd "  [string trim $sql]"
  puts $::fd "} {$res}"
  puts $::fd ""
}

# Same as [execsql_test], except coerce all results to floating point values
# with two decimal points.
#
proc execsql_float_test {tn sql} {
  set F "%.2f"
  set res [execsql $sql]
  set res2 [list]
  foreach r $res { lappend res2 [format $F $r] }

  puts $::fd "do_test $tn {"
  puts $::fd "  set myres {}"
  puts $::fd "  foreach r \[db eval {[string trim $sql]}\] {"
  puts $::fd "    lappend myres \[format $F \[set r\]\]"
  puts $::fd "  }"
  puts $::fd "  set myres"
  puts $::fd "} {$res2}"
  puts $::fd ""
}

proc start_test {name date} {
  set dir [file dirname $::argv0]
  set output [file join $dir $name.test]
  set ::fd [open $output w]
puts $::fd [string trimleft "
# $date

Changes to test/window3.tcl.

125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161







162
163
164
165
166
167
    SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window )
    FROM t2
  "

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

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

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

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

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

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









}


finish_test








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






125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
    SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window )
    FROM t2
  "

  execsql_float_test 1.$tn.7.1 "
    SELECT percent_rank() OVER ( ORDER BY a $window ) FROM t2
  "
  execsql_float_test 1.$tn.7.2 "
    SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
  "
  execsql_float_test 1.$tn.7.3 "
    SELECT percent_rank() OVER ( ORDER BY b $window ) FROM t2
  "
  execsql_float_test 1.$tn.7.4 "
    SELECT percent_rank() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
  "
  execsql_float_test 1.$tn.7.5 "
    SELECT percent_rank() OVER ( ORDER BY b%10 $window ) FROM t2
  "
  execsql_float_test 1.$tn.7.6 "
    SELECT percent_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 $window ) FROM t2
  "

  execsql_float_test 1.$tn.8.1 "
    SELECT cume_dist() OVER ( ORDER BY a $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.2 "
    SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY a $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.3 "
    SELECT cume_dist() OVER ( ORDER BY b $window ) FROM t2
  "
  execsql_float_test 1.$tn.8.4 "
    SELECT cume_dist() OVER ( PARTITION BY b%10 ORDER BY b $window ) FROM t2
  "
  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

Changes to test/window3.test.

125
126
127
128
129
130
131
132
133
134
135
136
137











138
139

140
141
142

143











144
145

146
147
148

149



150
151

152
153
154












155
156
157
158
159
160
161
...
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
...
317
318
319
320
321
322
323
324
325
326
327
328
329











330
331

332
333
334

335











336
337

338
339
340

341



342
343

344
345
346












347
348
349
350
351
352
353
...
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
...
509
510
511
512
513
514
515
516
517
518
519
520
521











522
523

524
525
526

527











528
529

530
531
532

533



534
535

536
537
538












539
540
541
542
543
544
545
...
605
606
607
608
609
610
611
612
613
614
615
616
617











618
619

620
621
622

623











624
625

626
627
628

629



630
631

632
633
634












635
636
637
638
639
640
641
...
701
702
703
704
705
706
707
708
709
710
711
712
713











714
715

716
717
718

719











720
721

722
723
724

725



726
727

728
729
730












731
732
733
734
735
736
737
...
797
798
799
800
801
802
803
804
805
806
807
808
809











810
811

812
813
814

815











816
817

818
819
820

821



822
823

824
825
826












827
828
829
830
831
832
833
...
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
...
989
990
991
992
993
994
995
996
997
998
999
1000
1001











1002
1003

1004
1005
1006

1007











1008
1009

1010
1011
1012

1013



1014
1015

1016
1017
1018












1019
1020
1021
1022
1023
1024
1025
....
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
....
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193











1194
1195

1196
1197
1198

1199











1200
1201

1202
1203
1204

1205



1206
1207

1208
1209
1210












1211
1212
1213
1214
1215
1216
1217
....
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
....
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385











1386
1387

1388
1389
1390

1391











1392
1393

1394
1395
1396

1397



1398
1399

1400
1401
1402












1403
1404
1405
1406
1407
1408
1409
....
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481











1482
1483

1484
1485
1486

1487











1488
1489

1490
1491
1492

1493



1494
1495

1496
1497
1498












1499
1500
1501
1502
1503
1504
1505
....
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577











1578
1579

1580
1581
1582

1583











1584
1585

1586
1587
1588

1589



1590
1591

1592
1593
1594












1595
1596
1597
1598
1599
1600
1601
....
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673











1674
1675

1676
1677
1678

1679











1680
1681

1682
1683
1684

1685



1686
1687

1688
1689
1690

1691











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

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












do_execsql_test 1.1.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.1.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.1.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.2.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.2.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.2.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.3.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.3.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.3.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.4.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.4.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.4.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.5.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.5.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.5.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.6.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.6.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.6.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.7.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.7.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.7.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.8.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.8.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.8.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.9.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.9.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.9.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.10.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.10.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.10.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.11.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.11.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.11.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.12.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.12.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.12.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.13.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.13.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.13.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.14.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.14.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.14.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.15.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.15.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.15.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.16.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.16.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.16.7.6 {
  SELECT CAST( round( 100 * 

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













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

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

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












do_execsql_test 1.17.7.3 {
  SELECT CAST( round( 100 * 

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













do_execsql_test 1.17.7.5 {
  SELECT CAST( round( 100 * 

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





do_execsql_test 1.17.7.6 {
  SELECT CAST( round( 100 * 

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













finish_test







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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







 







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

125
126
127
128
129
130
131
132
133
134
135

136
137
138
139
140
141
142
143
144
145
146
147
148

149
150


151
152
153
154
155
156
157
158
159
160
161
162
163
164

165
166


167
168
169
170
171
172

173
174


175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
...
253
254
255
256
257
258
259
260
261
262
263

264
265
266
267
268
269
270
271
272
273
274
275
276

277
278


279
280
281
282
283
284
285
286
287
288
289
290
291
292

293
294


295
296
297
298
299
300

301
302


303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
...
381
382
383
384
385
386
387
388
389
390
391

392
393
394
395
396
397
398
399
400
401
402
403
404

405
406


407
408
409
410
411
412
413
414
415
416
417
418
419
420

421
422


423
424
425
426
427
428

429
430


431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
509
510
511
512
513
514
515
516
517
518
519

520
521
522
523
524
525
526
527
528
529
530
531
532

533
534


535
536
537
538
539
540
541
542
543
544
545
546
547
548

549
550


551
552
553
554
555
556

557
558


559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
...
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
...
765
766
767
768
769
770
771
772
773
774
775

776
777
778
779
780
781
782
783
784
785
786
787
788

789
790


791
792
793
794
795
796
797
798
799
800
801
802
803
804

805
806


807
808
809
810
811
812

813
814


815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
...
893
894
895
896
897
898
899
900
901
902
903

904
905
906
907
908
909
910
911
912
913
914
915
916

917
918


919
920
921
922
923
924
925
926
927
928
929
930
931
932

933
934


935
936
937
938
939
940

941
942


943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
....
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031

1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044

1045
1046


1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060

1061
1062


1063
1064
1065
1066
1067
1068

1069
1070


1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
....
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159

1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172

1173
1174


1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188

1189
1190


1191
1192
1193
1194
1195
1196

1197
1198


1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
....
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
....
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415

1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428

1429
1430


1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444

1445
1446


1447
1448
1449
1450
1451
1452

1453
1454


1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
....
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543

1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556

1557
1558


1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572

1573
1574


1575
1576
1577
1578
1579
1580

1581
1582


1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
....
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671

1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684

1685
1686


1687
1688
1689
1690
1691
1692
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
....
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799

1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812

1813
1814


1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828

1829
1830


1831
1832
1833
1834
1835
1836

1837
1838


1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
....
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
....
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055

2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068

2069
2070


2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084

2085
2086


2087
2088
2089
2090
2091
2092

2093
2094


2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
....
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
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
  SELECT 
      row_number() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
      rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
      dense_rank() OVER ( PARTITION BY b%2 ORDER BY b%10 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
    FROM t2
} {1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 16 2   17 16 2   18 16 2   19 16 2   20 16 2   21 16 2   22 16 2   23 16 2   24 16 2   25 16 2   26 16 2   27 16 2   28 16 2   29 16 2   30 16 2   31 16 2   32 16 2   33 33 3   34 33 3   35 33 3   36 33 3   37 33 3   38 33 3   39 33 3   40 33 3   41 33 3   42 33 3   43 33 3   44 33 3   45 33 3   46 33 3   47 33 3   48 33 3   49 33 3   50 33 3   51 33 3   52 33 3   53 33 3   54 54 4   55 54 4   56 54 4   57 54 4   58 54 4   59 54 4   60 54 4   61 54 4   62 54 4   63 54 4   64 54 4   65 54 4   66 54 4   67 54 4   68 54 4   69 54 4   70 54 4   71 54 4   72 54 4   73 54 4   74 54 4   75 54 4   76 76 5   77 76 5   78 76 5   79 76 5   80 76 5   81 76 5   82 76 5   83 76 5   84 76 5   85 76 5   86 76 5   87 76 5   88 76 5   89 76 5   90 76 5   91 76 5   1 1 1   2 1 1   3 1 1   4 1 1   5 1 1   6 1 1   7 1 1   8 1 1   9 1 1   10 1 1   11 1 1   12 1 1   13 1 1   14 1 1   15 1 1   16 1 1   17 1 1   18 1 1   19 1 1   20 1 1   21 1 1   22 1 1   23 23 2   24 23 2   25 23 2   26 23 2   27 23 2   28 23 2   29 23 2   30 23 2   31 23 2   32 23 2   33 23 2   34 23 2   35 23 2   36 23 2   37 23 2   38 23 2   39 23 2   40 23 2   41 23 2   42 23 2   43 23 2   44 23 2   45 23 2   46 46 3   47 46 3   48 46 3   49 46 3   50 46 3   51 46 3   52 46 3   53 46 3   54 46 3   55 46 3   56 46 3   57 46 3   58 46 3   59 46 3   60 46 3   61 46 3   62 46 3   63 46 3   64 46 3   65 46 3   66 46 3   67 67 4   68 67 4   69 67 4   70 67 4   71 67 4   72 67 4   73 67 4   74 67 4   75 67 4   76 67 4   77 67 4   78 67 4   79 67 4   80 67 4   81 67 4   82 67 4   83 67 4   84 67 4   85 67 4   86 67 4   87 87 5   88 87 5   89 87 5   90 87 5   91 87 5   92 87 5   93 87 5   94 87 5   95 87 5   96 87 5   97 87 5   98 87 5   99 87 5   100 87 5   101 87 5   102 87 5   103 87 5   104 87 5   105 87 5   106 87 5   107 87 5   108 87 5   109 87 5}

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.1.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.1.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.1.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 RANGE 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.1.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.2.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.2.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.2.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.2.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.3.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.3.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.3.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.3.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.4.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.4.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.4.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.4.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.5.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.5.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.5.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.5.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.6.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.6.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.6.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.6.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.7.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.7.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.7.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.7.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.8.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.8.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.8.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.8.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.9.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.9.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.9.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.9.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.10.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.10.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.10.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.10.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.11.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.11.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.11.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.11.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.12.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.12.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.12.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.12.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.13.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.13.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.13.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.13.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.14.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.14.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.14.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.14.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.15.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.15.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.15.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.15.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.16.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.16.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.16.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.16.7.6 {

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

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

  }
  set myres
} {0.00 0.01 0.01 0.02 0.02 0.03 0.03 0.04 0.04 0.05 0.05 0.06 0.06 0.07 0.07 0.08 0.08 0.09 0.09 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.14 0.14 0.15 0.15 0.16 0.16 0.17 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.21 0.21 0.22 0.22 0.23 0.23 0.24 0.24 0.25 0.25 0.26 0.26 0.27 0.27 0.28 0.28 0.29 0.29 0.30 0.30 0.31 0.31 0.32 0.32 0.33 0.33 0.34 0.34 0.35 0.35 0.36 0.36 0.37 0.37 0.38 0.38 0.39 0.39 0.40 0.40 0.41 0.41 0.42 0.42 0.43 0.43 0.44 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.49 0.49 0.50 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.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.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.70 0.70 0.71 0.71 0.72 0.72 0.73 0.73 0.74 0.74 0.75 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.82 0.82 0.83 0.83 0.84 0.84 0.85 0.85 0.86 0.86 0.87 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.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.7.2 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.29 0.36 0.43 0.50 0.57 0.64 0.71 0.79 0.86 0.93 1.00 0.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.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.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.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.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.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.00 0.05 0.11 0.16 0.21 0.26 0.32 0.37 0.42 0.47 0.53 0.58 0.63 0.68 0.74 0.79 0.84 0.89 0.95 1.00 0.00 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.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}

do_test 1.17.7.3 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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 0.01 0.02 0.02 0.02 0.03 0.03 0.04 0.05 0.05 0.06 0.06 0.06 0.07 0.07 0.07 0.09 0.09 0.09 0.10 0.11 0.11 0.12 0.12 0.12 0.13 0.13 0.14 0.15 0.15 0.15 0.16 0.16 0.16 0.18 0.18 0.19 0.19 0.19 0.20 0.20 0.21 0.21 0.21 0.23 0.23 0.24 0.24 0.24 0.25 0.25 0.26 0.27 0.27 0.27 0.28 0.28 0.28 0.30 0.30 0.31 0.31 0.31 0.31 0.31 0.31 0.34 0.34 0.34 0.34 0.36 0.36 0.37 0.37 0.37 0.37 0.39 0.39 0.40 0.40 0.41 0.41 0.41 0.42 0.43 0.43 0.43 0.44 0.45 0.45 0.46 0.46 0.47 0.47 0.48 0.48 0.48 0.48 0.50 0.50 0.51 0.51 0.52 0.52 0.53 0.53 0.54 0.54 0.54 0.55 0.56 0.56 0.56 0.56 0.58 0.58 0.58 0.58 0.60 0.60 0.60 0.61 0.61 0.62 0.63 0.63 0.63 0.63 0.65 0.65 0.66 0.66 0.67 0.67 0.67 0.67 0.69 0.69 0.69 0.70 0.70 0.70 0.70 0.70 0.73 0.73 0.73 0.74 0.75 0.75 0.76 0.76 0.77 0.77 0.77 0.78 0.78 0.78 0.80 0.80 0.81 0.81 0.81 0.81 0.83 0.83 0.83 0.84 0.85 0.85 0.86 0.86 0.86 0.86 0.88 0.88 0.88 0.89 0.89 0.89 0.89 0.89 0.92 0.92 0.92 0.93 0.94 0.94 0.94 0.95 0.95 0.95 0.97 0.97 0.98 0.98 0.99 0.99 0.99}

do_test 1.17.7.4 {
  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.07 0.14 0.21 0.21 0.21 0.43 0.50 0.57 0.64 0.71 0.71 0.86 0.86 0.86 0.00 0.00 0.10 0.10 0.19 0.19 0.29 0.29 0.38 0.38 0.38 0.52 0.57 0.57 0.67 0.67 0.67 0.81 0.81 0.81 0.81 0.81 0.00 0.00 0.00 0.19 0.19 0.19 0.38 0.38 0.50 0.56 0.62 0.69 0.69 0.81 0.81 0.81 1.00 0.00 0.00 0.09 0.09 0.18 0.18 0.18 0.32 0.32 0.32 0.32 0.32 0.55 0.55 0.64 0.68 0.73 0.73 0.73 0.86 0.91 0.91 0.91 0.00 0.05 0.10 0.15 0.15 0.15 0.15 0.35 0.35 0.45 0.50 0.55 0.55 0.55 0.55 0.55 0.80 0.80 0.80 0.80 1.00 0.00 0.05 0.05 0.05 0.20 0.25 0.25 0.35 0.35 0.45 0.45 0.45 0.60 0.60 0.60 0.75 0.75 0.75 0.90 0.90 0.90 0.00 0.05 0.05 0.05 0.19 0.19 0.19 0.33 0.33 0.33 0.33 0.52 0.52 0.62 0.62 0.62 0.76 0.81 0.86 0.90 0.90 0.90 0.00 0.00 0.00 0.16 0.21 0.21 0.32 0.32 0.42 0.42 0.42 0.42 0.63 0.68 0.74 0.74 0.84 0.84 0.95 0.95 0.00 0.00 0.00 0.20 0.27 0.27 0.40 0.40 0.40 0.40 0.67 0.73 0.73 0.87 0.93 0.93 0.00 0.00 0.00 0.14 0.18 0.18 0.18 0.32 0.32 0.32 0.45 0.50 0.50 0.50 0.50 0.68 0.73 0.77 0.77 0.77 0.91 0.91 0.91}

do_test 1.17.7.5 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() OVER ( ORDER BY b%10 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.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.08 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 0.19 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.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.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.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.60 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 0.71 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 0.89 0.89 0.89 0.89 0.89 0.89 0.89}

do_test 1.17.7.6 {

  set myres {}
  foreach r [db eval {SELECT percent_rank() 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.00 0.00 0.00 0.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