summaryrefslogtreecommitdiffstats
path: root/test/window8.test
blob: 0c5d39badb951188daf59df867382b2224ea030d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
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
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
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
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
# 2019 March 01
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#

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

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

ifcapable !windowfunc { finish_test ; return }
do_execsql_test 1.0 {
  DROP TABLE IF EXISTS t3;
  CREATE TABLE t3(a TEXT, b TEXT, c INTEGER);
  INSERT INTO t3 VALUES
    ('HH', 'bb', 355), ('CC', 'aa', 158), ('BB', 'aa', 399), 
    ('FF', 'bb', 938), ('HH', 'aa', 480), ('FF', 'bb', 870), 
    ('JJ', 'aa', 768), ('JJ', 'aa', 899), ('GG', 'bb', 929), 
    ('II', 'bb', 421), ('GG', 'bb', 844), ('FF', 'bb', 574), 
    ('CC', 'bb', 822), ('GG', 'bb', 938), ('BB', 'aa', 660), 
    ('HH', 'aa', 979), ('BB', 'bb', 792), ('DD', 'aa', 845), 
    ('JJ', 'bb', 354), ('FF', 'bb', 295), ('JJ', 'aa', 234), 
    ('BB', 'bb', 840), ('AA', 'aa', 934), ('EE', 'aa', 113), 
    ('AA', 'bb', 309), ('BB', 'aa', 412), ('AA', 'aa', 911), 
    ('AA', 'bb', 572), ('II', 'aa', 398), ('II', 'bb', 250), 
    ('II', 'aa', 652), ('BB', 'bb', 633), ('AA', 'aa', 239), 
    ('FF', 'aa', 670), ('BB', 'bb', 705), ('HH', 'bb', 963), 
    ('CC', 'bb', 346), ('II', 'bb', 671), ('BB', 'aa', 247), 
    ('AA', 'aa', 223), ('GG', 'aa', 480), ('HH', 'aa', 790), 
    ('FF', 'aa', 208), ('BB', 'bb', 711), ('EE', 'aa', 777), 
    ('DD', 'bb', 716), ('CC', 'aa', 759), ('CC', 'aa', 430), 
    ('CC', 'aa', 607), ('DD', 'bb', 794), ('GG', 'aa', 148), 
    ('GG', 'aa', 634), ('JJ', 'bb', 257), ('DD', 'bb', 959), 
    ('FF', 'bb', 726), ('BB', 'aa', 762), ('JJ', 'bb', 336), 
    ('GG', 'aa', 335), ('HH', 'bb', 330), ('GG', 'bb', 160), 
    ('JJ', 'bb', 839), ('FF', 'aa', 618), ('BB', 'aa', 393), 
    ('EE', 'bb', 629), ('FF', 'aa', 667), ('AA', 'bb', 870), 
    ('FF', 'bb', 102), ('JJ', 'aa', 113), ('DD', 'aa', 224), 
    ('AA', 'bb', 627), ('HH', 'bb', 730), ('II', 'bb', 443), 
    ('HH', 'bb', 133), ('EE', 'bb', 252), ('II', 'bb', 805), 
    ('BB', 'bb', 786), ('EE', 'bb', 768), ('HH', 'bb', 683), 
    ('DD', 'bb', 238), ('DD', 'aa', 256);
} {}

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

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

do_execsql_test 1.1.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

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

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

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

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

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

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

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

do_execsql_test 1.2.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

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

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

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

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

do_execsql_test 1.2.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751 4685 1373 2307   AA aa 3774 4685 1396 2307
  AA aa 4446 4685 2068 2307   AA aa 4462 4685 2084 2307
  AA bb 3815 4685 3815 4685   AA bb 4058 4685 4058 4685
  AA bb 4113 4685 4113 4685   AA bb 4376 4685 4376 4685
  BB aa 11263 12025 6796 7558   BB aa 11365 12025 6898 7558
  BB aa 11613 12025 7146 7558   BB aa 11626 12025 7159 7558
  BB aa 11632 12025 7165 7558   BB aa 11778 12025 7311 7558
  BB bb 11185 12025 11185 12025   BB bb 11233 12025 11233 12025
  BB bb 11239 12025 11239 12025   BB bb 11314 12025 11314 12025
  BB bb 11320 12025 11320 12025   BB bb 11392 12025 11392 12025
  CC aa 14388 15147 13220 13979   CC aa 14540 15147 13372 13979
  CC aa 14717 15147 13549 13979   CC aa 14989 15147 13821 13979
  CC bb 14325 15147 14325 15147   CC bb 14801 15147 14801 15147
  DD aa 18334 19179 15627 16472   DD aa 18923 19179 16216 16472
  DD aa 18955 19179 16248 16472   DD bb 18220 19179 18220 19179
  DD bb 18385 19179 18385 19179   DD bb 18463 19179 18463 19179
  DD bb 18941 19179 18941 19179   EE aa 20941 21718 19292 20069
  EE aa 21605 21718 19956 20069   EE bb 20950 21718 20950 21718
  EE bb 21089 21718 21089 21718   EE bb 21466 21718 21466 21718
  FF aa 26716 27386 23211 23881   FF aa 26719 27386 23214 23881
  FF aa 26768 27386 23263 23881   FF aa 27178 27386 23673 23881
  FF bb 26448 27386 26448 27386   FF bb 26516 27386 26516 27386
  FF bb 26660 27386 26660 27386   FF bb 26812 27386 26812 27386
  FF bb 27091 27386 27091 27386   FF bb 27284 27386 27284 27386
  GG aa 31220 31854 28349 28983   GG aa 31374 31854 28503 28983
  GG aa 31519 31854 28648 28983   GG aa 31706 31854 28835 28983
  GG bb 30916 31854 30916 31854   GG bb 30925 31854 30925 31854
  GG bb 31010 31854 31010 31854   GG bb 31694 31854 31694 31854
  HH aa 36318 37297 33124 34103   HH aa 36507 37297 33313 34103
  HH aa 36817 37297 33623 34103   HH bb 36334 37297 36334 37297
  HH bb 36567 37297 36567 37297   HH bb 36614 37297 36614 37297
  HH bb 36942 37297 36942 37297   HH bb 36967 37297 36967 37297
  HH bb 37164 37297 37164 37297   II aa 40285 40937 37695 38347
  II aa 40539 40937 37949 38347   II bb 40132 40937 40132 40937
  II bb 40266 40937 40266 40937   II bb 40494 40937 40494 40937
  II bb 40516 40937 40516 40937   II bb 40687 40937 40687 40937
  JJ aa 43838 44737 42052 42951   JJ aa 43969 44737 42183 42951
  JJ aa 44503 44737 42717 42951   JJ aa 44624 44737 42838 42951
  JJ bb 43898 44737 43898 44737   JJ bb 44383 44737 44383 44737
  JJ bb 44401 44737 44401 44737   JJ bb 44480 44737 44480 44737}

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

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

do_execsql_test 1.3.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

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

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

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

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

do_execsql_test 1.3.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN UNBOUNDED PRECEDING AND 1 FOLLOWING )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 11091 12025 3751 4685   AA aa 11114 12025 3774 4685
  AA aa 11786 12025 4446 4685   AA aa 11802 12025 4462 4685
  AA bb 11155 12025 6688 7558   AA bb 11398 12025 6931 7558
  AA bb 11453 12025 6986 7558   AA bb 11716 12025 7249 7558
  BB aa 14385 15147 11263 12025   BB aa 14487 15147 11365 12025
  BB aa 14735 15147 11613 12025   BB aa 14748 15147 11626 12025
  BB aa 14754 15147 11632 12025   BB aa 14900 15147 11778 12025
  BB bb 14307 15147 13139 13979   BB bb 14355 15147 13187 13979
  BB bb 14361 15147 13193 13979   BB bb 14436 15147 13268 13979
  BB bb 14442 15147 13274 13979   BB bb 14514 15147 13346 13979
  CC aa 18420 19179 14388 15147   CC aa 18572 19179 14540 15147
  CC aa 18749 19179 14717 15147   CC aa 19021 19179 14989 15147
  CC bb 18357 19179 15650 16472   CC bb 18833 19179 16126 16472
  DD aa 20873 21718 18334 19179   DD aa 21462 21718 18923 19179
  DD aa 21494 21718 18955 19179   DD bb 20759 21718 19110 20069
  DD bb 20924 21718 19275 20069   DD bb 21002 21718 19353 20069
  DD bb 21480 21718 19831 20069   EE aa 26609 27386 20941 21718
  EE aa 27273 27386 21605 21718   EE bb 26618 27386 23113 23881
  EE bb 26757 27386 23252 23881   EE bb 27134 27386 23629 23881
  FF aa 31184 31854 26716 27386   FF aa 31187 31854 26719 27386
  FF aa 31236 31854 26768 27386   FF aa 31646 31854 27178 27386
  FF bb 30916 31854 28045 28983   FF bb 30984 31854 28113 28983
  FF bb 31128 31854 28257 28983   FF bb 31280 31854 28409 28983
  FF bb 31559 31854 28688 28983   FF bb 31752 31854 28881 28983
  GG aa 36663 37297 31220 31854   GG aa 36817 37297 31374 31854
  GG aa 36962 37297 31519 31854   GG aa 37149 37297 31706 31854
  GG bb 36359 37297 33165 34103   GG bb 36368 37297 33174 34103
  GG bb 36453 37297 33259 34103   GG bb 37137 37297 33943 34103
  HH aa 39958 40937 36318 37297   HH aa 40147 40937 36507 37297
  HH aa 40457 40937 36817 37297   HH bb 39974 40937 37384 38347
  HH bb 40207 40937 37617 38347   HH bb 40254 40937 37664 38347
  HH bb 40582 40937 37992 38347   HH bb 40607 40937 38017 38347
  HH bb 40804 40937 38214 38347   II aa 44085 44737 40285 40937
  II aa 44339 44737 40539 40937   II bb 43932 44737 42146 42951
  II bb 44066 44737 42280 42951   II bb 44294 44737 42508 42951
  II bb 44316 44737 42530 42951   II bb 44487 44737 42701 42951
  JJ aa 43838 44737 43838 44737   JJ aa 43969 44737 43969 44737
  JJ aa 44503 44737 44503 44737   JJ aa 44624 44737 44624 44737
  JJ bb 43898 44737 43898 44737   JJ bb 44383 44737 44383 44737
  JJ bb 44401 44737 44401 44737   JJ bb 44480 44737 44480 44737}

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

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

do_execsql_test 1.4.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

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

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

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

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

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

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

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

do_execsql_test 1.5.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 1 PRECEDING         AND 2 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

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

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

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

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

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

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

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

do_execsql_test 1.6.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.6.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 934   AA bb 934
  AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934
  BB aa 934   BB aa 934   BB bb 870   BB bb 870   BB bb 870   BB bb 870
  BB bb 870   BB bb 870   CC aa 840   CC aa 840   CC aa 840   CC aa 840
  CC bb 840   CC bb 840   DD aa 822   DD aa 822   DD aa 822   DD bb 845
  DD bb 845   DD bb 845   DD bb 845   EE aa 959   EE aa 959   EE bb 959
  EE bb 959   EE bb 959   FF aa 777   FF aa 777   FF aa 777   FF aa 777
  FF bb 768   FF bb 768   FF bb 768   FF bb 768   FF bb 768   FF bb 768
  GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938
  GG bb 938   GG bb 938   HH aa 938   HH aa 938   HH aa 938   HH bb 979
  HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979
  II aa 979   II bb 963   II bb 963   II bb 963   II bb 963   II bb 963
  JJ aa 805   JJ aa 805   JJ aa 805   JJ aa 805   JJ bb 899   JJ bb 899
  JJ bb 899   JJ bb 899}

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

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

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

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

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

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

do_execsql_test 1.7.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.7.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 1 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa {}   AA aa {}   AA aa {}   AA aa {}   AA bb 934   AA bb 934
  AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934
  BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934
  BB bb 934   BB bb 934   CC aa 870   CC aa 870   CC aa 870   CC aa 870
  CC bb 840   CC bb 840   DD aa 840   DD aa 840   DD aa 840   DD bb 845
  DD bb 845   DD bb 845   DD bb 845   EE aa 959   EE aa 959   EE bb 959
  EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959
  FF bb 777   FF bb 777   FF bb 777   FF bb 777   FF bb 777   FF bb 777
  GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938
  GG bb 938   GG bb 938   HH aa 938   HH aa 938   HH aa 938   HH bb 979
  HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979
  II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979
  JJ aa 963   JJ aa 963   JJ aa 963   JJ aa 963   JJ bb 899   JJ bb 899
  JJ bb 899   JJ bb 899}

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

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

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

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

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

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

do_execsql_test 1.8.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.8.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934
  AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934
  BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934
  BB bb 934   BB bb 934   CC aa 870   CC aa 870   CC aa 870   CC aa 870
  CC bb 840   CC bb 840   DD aa 845   DD aa 845   DD aa 845   DD bb 959
  DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959
  EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959
  FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938
  GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938
  GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 979
  HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979
  II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979
  JJ aa 963   JJ aa 963   JJ aa 963   JJ aa 963   JJ bb 899   JJ bb 899
  JJ bb 899   JJ bb 899}

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

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

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

do_execsql_test 1.8.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 PRECEDING )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751 4685 1373 2307   AA aa 3774 4685 1396 2307
  AA aa 4446 4685 2068 2307   AA aa 4462 4685 2084 2307
  AA bb 3815 4685 3815 4685   AA bb 4058 4685 4058 4685
  AA bb 4113 4685 4113 4685   AA bb 4376 4685 4376 4685
  BB aa 11263 12025 6796 7558   BB aa 11365 12025 6898 7558
  BB aa 11613 12025 7146 7558   BB aa 11626 12025 7159 7558
  BB aa 11632 12025 7165 7558   BB aa 11778 12025 7311 7558
  BB bb 11185 12025 11185 12025   BB bb 11233 12025 11233 12025
  BB bb 11239 12025 11239 12025   BB bb 11314 12025 11314 12025
  BB bb 11320 12025 11320 12025   BB bb 11392 12025 11392 12025
  CC aa 14388 15147 10913 11672   CC aa 14540 15147 11065 11672
  CC aa 14717 15147 11242 11672   CC aa 14989 15147 11514 11672
  CC bb 14325 15147 9640 10462   CC bb 14801 15147 10116 10462
  DD aa 18334 19179 8069 8914   DD aa 18923 19179 8658 8914
  DD aa 18955 19179 8690 8914   DD bb 18220 19179 6195 7154
  DD bb 18385 19179 6360 7154   DD bb 18463 19179 6438 7154
  DD bb 18941 19179 6916 7154   EE aa 16256 17033 5313 6090
  EE aa 16920 17033 5977 6090   EE bb 16265 17033 5803 6571
  EE bb 16404 17033 5942 6571   EE bb 16781 17033 6319 6571
  FF aa 14691 15361 6739 7409   FF aa 14694 15361 6742 7409
  FF aa 14743 15361 6791 7409   FF aa 15153 15361 7201 7409
  FF bb 14423 15361 7269 8207   FF bb 14491 15361 7337 8207
  FF bb 14635 15361 7481 8207   FF bb 14787 15361 7633 8207
  FF bb 15066 15361 7912 8207   FF bb 15259 15361 8105 8207
  GG aa 16073 16707 8280 8914   GG aa 16227 16707 8434 8914
  GG aa 16372 16707 8579 8914   GG aa 16559 16707 8766 8914
  GG bb 15769 16707 9198 10136   GG bb 15778 16707 9207 10136
  GG bb 15863 16707 9292 10136   GG bb 16547 16707 9976 10136
  HH aa 17139 18118 9243 10222   HH aa 17328 18118 9432 10222
  HH aa 17638 18118 9742 10222   HH bb 17155 18118 8948 9911
  HH bb 17388 18118 9181 9911   HH bb 17435 18118 9228 9911
  HH bb 17763 18118 9556 9911   HH bb 17788 18118 9581 9911
  HH bb 17985 18118 9778 9911   II aa 18567 19219 8712 9364
  II aa 18821 19219 8966 9364   II bb 18414 19219 8278 9083
  II bb 18548 19219 8412 9083   II bb 18776 19219 8640 9083
  II bb 18798 19219 8662 9083   II bb 18969 19219 8833 9083
  JJ aa 16452 17351 7949 8848   JJ aa 16583 17351 8080 8848
  JJ aa 17117 17351 8614 8848   JJ aa 17238 17351 8735 8848
  JJ bb 16512 17351 6601 7440   JJ bb 16997 17351 7086 7440
  JJ bb 17015 17351 7104 7440   JJ bb 17094 17351 7183 7440}

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

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

do_execsql_test 1.9.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.9.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934
  AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934
  BB aa 934   BB aa 934   BB bb 870   BB bb 870   BB bb 870   BB bb 870
  BB bb 870   BB bb 870   CC aa 840   CC aa 840   CC aa 840   CC aa 840
  CC bb 840   CC bb 840   DD aa 845   DD aa 845   DD aa 845   DD bb 959
  DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959
  EE bb 959   EE bb 959   FF aa 777   FF aa 777   FF aa 777   FF aa 777
  FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938
  GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938
  GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 979
  HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979
  II aa 979   II bb 963   II bb 963   II bb 963   II bb 963   II bb 963
  JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 899   JJ bb 899
  JJ bb 899   JJ bb 899}

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

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

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

do_execsql_test 1.9.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND CURRENT ROW )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751 4685 1373 2307   AA aa 3774 4685 1396 2307
  AA aa 4446 4685 2068 2307   AA aa 4462 4685 2084 2307
  AA bb 3815 4685 3815 4685   AA bb 4058 4685 4058 4685
  AA bb 4113 4685 4113 4685   AA bb 4376 4685 4376 4685
  BB aa 11263 12025 6796 7558   BB aa 11365 12025 6898 7558
  BB aa 11613 12025 7146 7558   BB aa 11626 12025 7159 7558
  BB aa 11632 12025 7165 7558   BB aa 11778 12025 7311 7558
  BB bb 11185 12025 8878 9718   BB bb 11233 12025 8926 9718
  BB bb 11239 12025 8932 9718   BB bb 11314 12025 9007 9718
  BB bb 11320 12025 9013 9718   BB bb 11392 12025 9085 9718
  CC aa 14388 15147 8535 9294   CC aa 14540 15147 8687 9294
  CC aa 14717 15147 8864 9294   CC aa 14989 15147 9136 9294
  CC bb 14325 15147 6767 7589   CC bb 14801 15147 7243 7589
  DD aa 13649 14494 3602 4447   DD aa 14238 14494 4191 4447
  DD aa 14270 14494 4223 4447   DD bb 13535 14494 4241 5200
  DD bb 13700 14494 4406 5200   DD bb 13778 14494 4484 5200
  DD bb 14256 14494 4962 5200   EE aa 8916 9693 4145 4922
  EE aa 9580 9693 4809 4922   EE bb 8925 9693 4478 5246
  EE bb 9064 9693 4617 5246   EE bb 9441 9693 4994 5246
  FF aa 11569 12239 4032 4702   FF aa 11572 12239 4035 4702
  FF aa 11621 12239 4084 4702   FF aa 12031 12239 4494 4702
  FF bb 11301 12239 6379 7317   FF bb 11369 12239 6447 7317
  FF bb 11513 12239 6591 7317   FF bb 11665 12239 6743 7317
  FF bb 11944 12239 7022 7317   FF bb 12137 12239 7215 7317
  GG aa 12041 12675 6631 7265   GG aa 12195 12675 6785 7265
  GG aa 12340 12675 6930 7265   GG aa 12527 12675 7117 7265
  GG bb 11737 12675 7035 7973   GG bb 11746 12675 7044 7973
  GG bb 11831 12675 7129 7973   GG bb 12515 12675 7813 7973
  HH aa 14600 15579 5738 6717   HH aa 14789 15579 5927 6717
  HH aa 15099 15579 6237 6717   HH bb 14616 15579 7351 8314
  HH bb 14849 15579 7584 8314   HH bb 14896 15579 7631 8314
  HH bb 15224 15579 7959 8314   HH bb 15249 15579 7984 8314
  HH bb 15446 15579 8181 8314   II aa 12899 13551 5841 6493
  II aa 13153 13551 6095 6493   II bb 12746 13551 6029 6834
  II bb 12880 13551 6163 6834   II bb 13108 13551 6391 6834
  II bb 13130 13551 6413 6834   II bb 13301 13551 6584 6834
  JJ aa 11984 12883 4755 5654   JJ aa 12115 12883 4886 5654
  JJ aa 12649 12883 5420 5654   JJ aa 12770 12883 5541 5654
  JJ bb 12044 12883 5551 6390   JJ bb 12529 12883 6036 6390
  JJ bb 12547 12883 6054 6390   JJ bb 12626 12883 6133 6390}

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

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

do_execsql_test 1.10.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.10.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 934   AA bb 934
  AA bb 934   AA bb 934   BB aa 934   BB aa 934   BB aa 934   BB aa 934
  BB aa 934   BB aa 934   BB bb 934   BB bb 934   BB bb 934   BB bb 934
  BB bb 934   BB bb 934   CC aa 870   CC aa 870   CC aa 870   CC aa 870
  CC bb 840   CC bb 840   DD aa 845   DD aa 845   DD aa 845   DD bb 959
  DD bb 959   DD bb 959   DD bb 959   EE aa 959   EE aa 959   EE bb 959
  EE bb 959   EE bb 959   FF aa 959   FF aa 959   FF aa 959   FF aa 959
  FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938
  GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 938   GG bb 938
  GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 979
  HH bb 979   HH bb 979   HH bb 979   HH bb 979   HH bb 979   II aa 979
  II aa 979   II bb 979   II bb 979   II bb 979   II bb 979   II bb 979
  JJ aa 963   JJ aa 963   JJ aa 963   JJ aa 963   JJ bb 899   JJ bb 899
  JJ bb 899   JJ bb 899}

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

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

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

do_execsql_test 1.10.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 3 PRECEDING         AND 0 FOLLOWING )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751 4685 1373 2307   AA aa 3774 4685 1396 2307
  AA aa 4446 4685 2068 2307   AA aa 4462 4685 2084 2307
  AA bb 3815 4685 3815 4685   AA bb 4058 4685 4058 4685
  AA bb 4113 4685 4113 4685   AA bb 4376 4685 4376 4685
  BB aa 11263 12025 6796 7558   BB aa 11365 12025 6898 7558
  BB aa 11613 12025 7146 7558   BB aa 11626 12025 7159 7558
  BB aa 11632 12025 7165 7558   BB aa 11778 12025 7311 7558
  BB bb 11185 12025 11185 12025   BB bb 11233 12025 11233 12025
  BB bb 11239 12025 11239 12025   BB bb 11314 12025 11314 12025
  BB bb 11320 12025 11320 12025   BB bb 11392 12025 11392 12025
  CC aa 14388 15147 10913 11672   CC aa 14540 15147 11065 11672
  CC aa 14717 15147 11242 11672   CC aa 14989 15147 11514 11672
  CC bb 14325 15147 9640 10462   CC bb 14801 15147 10116 10462
  DD aa 18334 19179 8069 8914   DD aa 18923 19179 8658 8914
  DD aa 18955 19179 8690 8914   DD bb 18220 19179 6195 7154
  DD bb 18385 19179 6360 7154   DD bb 18463 19179 6438 7154
  DD bb 18941 19179 6916 7154   EE aa 16256 17033 5313 6090
  EE aa 16920 17033 5977 6090   EE bb 16265 17033 5803 6571
  EE bb 16404 17033 5942 6571   EE bb 16781 17033 6319 6571
  FF aa 14691 15361 6739 7409   FF aa 14694 15361 6742 7409
  FF aa 14743 15361 6791 7409   FF aa 15153 15361 7201 7409
  FF bb 14423 15361 7269 8207   FF bb 14491 15361 7337 8207
  FF bb 14635 15361 7481 8207   FF bb 14787 15361 7633 8207
  FF bb 15066 15361 7912 8207   FF bb 15259 15361 8105 8207
  GG aa 16073 16707 8280 8914   GG aa 16227 16707 8434 8914
  GG aa 16372 16707 8579 8914   GG aa 16559 16707 8766 8914
  GG bb 15769 16707 9198 10136   GG bb 15778 16707 9207 10136
  GG bb 15863 16707 9292 10136   GG bb 16547 16707 9976 10136
  HH aa 17139 18118 9243 10222   HH aa 17328 18118 9432 10222
  HH aa 17638 18118 9742 10222   HH bb 17155 18118 8948 9911
  HH bb 17388 18118 9181 9911   HH bb 17435 18118 9228 9911
  HH bb 17763 18118 9556 9911   HH bb 17788 18118 9581 9911
  HH bb 17985 18118 9778 9911   II aa 18567 19219 8712 9364
  II aa 18821 19219 8966 9364   II bb 18414 19219 8278 9083
  II bb 18548 19219 8412 9083   II bb 18776 19219 8640 9083
  II bb 18798 19219 8662 9083   II bb 18969 19219 8833 9083
  JJ aa 16452 17351 7949 8848   JJ aa 16583 17351 8080 8848
  JJ aa 17117 17351 8614 8848   JJ aa 17238 17351 8735 8848
  JJ bb 16512 17351 6601 7440   JJ bb 16997 17351 7086 7440
  JJ bb 17015 17351 7104 7440   JJ bb 17094 17351 7183 7440}

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

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

do_execsql_test 1.11.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

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

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

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

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

do_execsql_test 1.11.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 2 PRECEDING         AND UNBOUNDED FOLLOWING )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803 44737 43803 44737   AA aa 43826 44737 43826 44737
  AA aa 44498 44737 44498 44737   AA aa 44514 44737 44514 44737
  AA bb 43867 44737 43867 44737   AA bb 44110 44737 44110 44737
  AA bb 44165 44737 44165 44737   AA bb 44428 44737 44428 44737
  BB aa 43975 44737 43975 44737   BB aa 44077 44737 44077 44737
  BB aa 44325 44737 44325 44737   BB aa 44338 44737 44338 44737
  BB aa 44344 44737 44344 44737   BB aa 44490 44737 44490 44737
  BB bb 43897 44737 41590 42430   BB bb 43945 44737 41638 42430
  BB bb 43951 44737 41644 42430   BB bb 44026 44737 41719 42430
  BB bb 44032 44737 41725 42430   BB bb 44104 44737 41797 42430
  CC aa 43978 44737 39293 40052   CC aa 44130 44737 39445 40052
  CC aa 44307 44737 39622 40052   CC aa 44579 44737 39894 40052
  CC bb 43915 44737 36357 37179   CC bb 44391 44737 36833 37179
  DD aa 39207 40052 31867 32712   DD aa 39796 40052 32456 32712
  DD aa 39828 40052 32488 32712   DD bb 39093 40052 29799 30758
  DD bb 39258 40052 29964 30758   DD bb 39336 40052 30042 30758
  DD bb 39814 40052 30520 30758   EE aa 31935 32712 28813 29590
  EE aa 32599 32712 29477 29590   EE bb 31944 32712 27497 28265
  EE bb 32083 32712 27636 28265   EE bb 32460 32712 28013 28265
  FF aa 28920 29590 24888 25558   FF aa 28923 29590 24891 25558
  FF aa 28972 29590 24940 25558   FF aa 29382 29590 25350 25558
  FF bb 28652 29590 23730 24668   FF bb 28720 29590 23798 24668
  FF bb 28864 29590 23942 24668   FF bb 29016 29590 24094 24668
  FF bb 29295 29590 24373 24668   FF bb 29488 29590 24566 24668
  GG aa 24924 25558 22385 23019   GG aa 25078 25558 22539 23019
  GG aa 25223 25558 22684 23019   GG aa 25410 25558 22871 23019
  GG bb 24620 25558 19918 20856   GG bb 24629 25558 19927 20856
  GG bb 24714 25558 20012 20856   GG bb 25398 25558 20696 20856
  HH aa 22040 23019 16372 17351   HH aa 22229 23019 16561 17351
  HH aa 22539 23019 16871 17351   HH bb 22056 23019 14791 15754
  HH bb 22289 23019 15024 15754   HH bb 22336 23019 15071 15754
  HH bb 22664 23019 15399 15754   HH bb 22689 23019 15424 15754
  HH bb 22886 23019 15621 15754   II aa 16699 17351 12231 12883
  II aa 16953 17351 12485 12883   II bb 16546 17351 9829 10634
  II bb 16680 17351 9963 10634   II bb 16908 17351 10191 10634
  II bb 16930 17351 10213 10634   II bb 17101 17351 10384 10634
  JJ aa 11984 12883 6541 7440   JJ aa 12115 12883 6672 7440
  JJ aa 12649 12883 7206 7440   JJ aa 12770 12883 7327 7440
  JJ bb 12044 12883 5551 6390   JJ bb 12529 12883 6036 6390
  JJ bb 12547 12883 6054 6390   JJ bb 12626 12883 6133 6390}

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

do_execsql_test 1.12.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 2378   AA bb 2378
  AA bb 2378   AA bb 2378   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873
  BB aa 2873   BB aa 2873   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467
  BB bb 4467   BB bb 4467   CC aa 1954   CC aa 1954   CC aa 1954   CC aa 1954
  CC bb 1168   CC bb 1168   DD aa 1325   DD aa 1325   DD aa 1325   DD bb 2707
  DD bb 2707   DD bb 2707   DD bb 2707   EE aa 890   EE aa 890   EE bb 1649
  EE bb 1649   EE bb 1649   FF aa 2163   FF aa 2163   FF aa 2163   FF aa 2163
  FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505
  GG aa 1597   GG aa 1597   GG aa 1597   GG aa 1597   GG bb 2871   GG bb 2871
  GG bb 2871   GG bb 2871   HH aa 2249   HH aa 2249   HH aa 2249   HH bb 3194
  HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   II aa 1050
  II aa 1050   II bb 2590   II bb 2590   II bb 2590   II bb 2590   II bb 2590
  JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ bb 1786   JJ bb 1786
  JJ bb 1786   JJ bb 1786}

do_execsql_test 1.12.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.12.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 870   AA bb 870
  AA bb 870   AA bb 870   BB aa 762   BB aa 762   BB aa 762   BB aa 762
  BB aa 762   BB aa 762   BB bb 840   BB bb 840   BB bb 840   BB bb 840
  BB bb 840   BB bb 840   CC aa 759   CC aa 759   CC aa 759   CC aa 759
  CC bb 822   CC bb 822   DD aa 845   DD aa 845   DD aa 845   DD bb 959
  DD bb 959   DD bb 959   DD bb 959   EE aa 777   EE aa 777   EE bb 768
  EE bb 768   EE bb 768   FF aa 670   FF aa 670   FF aa 670   FF aa 670
  FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938
  GG aa 634   GG aa 634   GG aa 634   GG aa 634   GG bb 938   GG bb 938
  GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 963
  HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 652
  II aa 652   II bb 805   II bb 805   II bb 805   II bb 805   II bb 805
  JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839
  JJ bb 839   JJ bb 839}

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

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

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

do_execsql_test 1.12.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 0 FOLLOWING )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751 4685 1373 2307   AA aa 3774 4685 1396 2307
  AA aa 4446 4685 2068 2307   AA aa 4462 4685 2084 2307
  AA bb 3815 4685 1508 2378   AA bb 4058 4685 1751 2378
  AA bb 4113 4685 1806 2378   AA bb 4376 4685 2069 2378
  BB aa 6578 7340 2111 2873   BB aa 6680 7340 2213 2873
  BB aa 6928 7340 2461 2873   BB aa 6941 7340 2474 2873
  BB aa 6947 7340 2480 2873   BB aa 7093 7340 2626 2873
  BB bb 6500 7340 3627 4467   BB bb 6548 7340 3675 4467
  BB bb 6554 7340 3681 4467   BB bb 6629 7340 3756 4467
  BB bb 6635 7340 3762 4467   BB bb 6707 7340 3834 4467
  CC aa 2363 3122 1195 1954   CC aa 2515 3122 1347 1954
  CC aa 2692 3122 1524 1954   CC aa 2964 3122 1796 1954
  CC bb 2300 3122 346 1168   CC bb 2776 3122 822 1168
  DD aa 3187 4032 480 1325   DD aa 3776 4032 1069 1325
  DD aa 3808 4032 1101 1325   DD bb 3073 4032 1748 2707
  DD bb 3238 4032 1913 2707   DD bb 3316 4032 1991 2707
  DD bb 3794 4032 2469 2707   EE aa 1762 2539 113 890
  EE aa 2426 2539 777 890   EE bb 1771 2539 881 1649
  EE bb 1910 2539 1020 1649   EE bb 2287 2539 1397 1649
  FF aa 4998 5668 1493 2163   FF aa 5001 5668 1496 2163
  FF aa 5050 5668 1545 2163   FF aa 5460 5668 1955 2163
  FF bb 4730 5668 2567 3505   FF bb 4798 5668 2635 3505
  FF bb 4942 5668 2779 3505   FF bb 5094 5668 2931 3505
  FF bb 5373 5668 3210 3505   FF bb 5566 5668 3403 3505
  GG aa 3834 4468 963 1597   GG aa 3988 4468 1117 1597
  GG aa 4133 4468 1262 1597   GG aa 4320 4468 1449 1597
  GG bb 3530 4468 1933 2871   GG bb 3539 4468 1942 2871
  GG bb 3624 4468 2027 2871   GG bb 4308 4468 2711 2871
  HH aa 4464 5443 1270 2249   HH aa 4653 5443 1459 2249
  HH aa 4963 5443 1769 2249   HH bb 4480 5443 2231 3194
  HH bb 4713 5443 2464 3194   HH bb 4760 5443 2511 3194
  HH bb 5088 5443 2839 3194   HH bb 5113 5443 2864 3194
  HH bb 5310 5443 3061 3194   II aa 2988 3640 398 1050
  II aa 3242 3640 652 1050   II bb 2835 3640 1785 2590
  II bb 2969 3640 1919 2590   II bb 3197 3640 2147 2590
  II bb 3219 3640 2169 2590   II bb 3390 3640 2340 2590
  JJ aa 2901 3800 1115 2014   JJ aa 3032 3800 1246 2014
  JJ aa 3566 3800 1780 2014   JJ aa 3687 3800 1901 2014
  JJ bb 2961 3800 947 1786   JJ bb 3446 3800 1432 1786
  JJ bb 3464 3800 1450 1786   JJ bb 3543 3800 1529 1786}

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

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

do_execsql_test 1.13.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.13.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 870   AA bb 870
  AA bb 870   AA bb 870   BB aa 840   BB aa 840   BB aa 840   BB aa 840
  BB aa 840   BB aa 840   BB bb 840   BB bb 840   BB bb 840   BB bb 840
  BB bb 840   BB bb 840   CC aa 822   CC aa 822   CC aa 822   CC aa 822
  CC bb 845   CC bb 845   DD aa 959   DD aa 959   DD aa 959   DD bb 959
  DD bb 959   DD bb 959   DD bb 959   EE aa 777   EE aa 777   EE bb 768
  EE bb 768   EE bb 768   FF aa 938   FF aa 938   FF aa 938   FF aa 938
  FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938
  GG aa 938   GG aa 938   GG aa 938   GG aa 938   GG bb 979   GG bb 979
  GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 963
  HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 805
  II aa 805   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899
  JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839
  JJ bb 839   JJ bb 839}

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

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

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

do_execsql_test 1.13.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 1 FOLLOWING )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 11091 12025 3751 4685   AA aa 11114 12025 3774 4685
  AA aa 11786 12025 4446 4685   AA aa 11802 12025 4462 4685
  AA bb 11155 12025 4381 5251   AA bb 11398 12025 4624 5251
  AA bb 11453 12025 4679 5251   AA bb 11716 12025 4942 5251
  BB aa 9700 10462 6578 7340   BB aa 9802 10462 6680 7340
  BB aa 10050 10462 6928 7340   BB aa 10063 10462 6941 7340
  BB aa 10069 10462 6947 7340   BB aa 10215 10462 7093 7340
  BB bb 9622 10462 5581 6421   BB bb 9670 10462 5629 6421
  BB bb 9676 10462 5635 6421   BB bb 9751 10462 5710 6421
  BB bb 9757 10462 5716 6421   BB bb 9829 10462 5788 6421
  CC aa 6395 7154 2363 3122   CC aa 6547 7154 2515 3122
  CC aa 6724 7154 2692 3122   CC aa 6996 7154 2964 3122
  CC bb 6332 7154 1671 2493   CC bb 6808 7154 2147 2493
  DD aa 5726 6571 3187 4032   DD aa 6315 6571 3776 4032
  DD aa 6347 6571 3808 4032   DD bb 5612 6571 2638 3597
  DD bb 5777 6571 2803 3597   DD bb 5855 6571 2881 3597
  DD bb 6333 6571 3359 3597   EE aa 7430 8207 1762 2539
  EE aa 8094 8207 2426 2539   EE bb 7439 8207 3044 3812
  EE bb 7578 8207 3183 3812   EE bb 7955 8207 3560 3812
  FF aa 9466 10136 4998 5668   FF aa 9469 10136 5001 5668
  FF aa 9518 10136 5050 5668   FF aa 9928 10136 5460 5668
  FF bb 9198 10136 4164 5102   FF bb 9266 10136 4232 5102
  FF bb 9410 10136 4376 5102   FF bb 9562 10136 4528 5102
  FF bb 9841 10136 4807 5102   FF bb 10034 10136 5000 5102
  GG aa 9277 9911 3834 4468   GG aa 9431 9911 3988 4468
  GG aa 9576 9911 4133 4468   GG aa 9763 9911 4320 4468
  GG bb 8973 9911 4182 5120   GG bb 8982 9911 4191 5120
  GG bb 9067 9911 4276 5120   GG bb 9751 9911 4960 5120
  HH aa 8104 9083 4464 5443   HH aa 8293 9083 4653 5443
  HH aa 8603 9083 4963 5443   HH bb 8120 9083 3281 4244
  HH bb 8353 9083 3514 4244   HH bb 8400 9083 3561 4244
  HH bb 8728 9083 3889 4244   HH bb 8753 9083 3914 4244
  HH bb 8950 9083 4111 4244   II aa 6788 7440 2988 3640
  II aa 7042 7440 3242 3640   II bb 6635 7440 3799 4604
  II bb 6769 7440 3933 4604   II bb 6997 7440 4161 4604
  II bb 7019 7440 4183 4604   II bb 7190 7440 4354 4604
  JJ aa 2901 3800 2901 3800   JJ aa 3032 3800 3032 3800
  JJ aa 3566 3800 3566 3800   JJ aa 3687 3800 3687 3800
  JJ bb 2961 3800 947 1786   JJ bb 3446 3800 1432 1786
  JJ bb 3464 3800 1450 1786   JJ bb 3543 3800 1529 1786}

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

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

do_execsql_test 1.14.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.14.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979
  AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979
  BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979
  BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979
  CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979
  DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979
  EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979
  FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979
  GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979
  GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 963
  HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 899
  II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899
  JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839
  JJ bb 839   JJ bb 839}

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

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

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

do_execsql_test 1.14.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND 100 FOLLOWING )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803 44737 43803 44737   AA aa 43826 44737 43826 44737
  AA aa 44498 44737 44498 44737   AA aa 44514 44737 44514 44737
  AA bb 43867 44737 41560 42430   AA bb 44110 44737 41803 42430
  AA bb 44165 44737 41858 42430   AA bb 44428 44737 42121 42430
  BB aa 39290 40052 39290 40052   BB aa 39392 40052 39392 40052
  BB aa 39640 40052 39640 40052   BB aa 39653 40052 39653 40052
  BB aa 39659 40052 39659 40052   BB aa 39805 40052 39805 40052
  BB bb 39212 40052 36339 37179   BB bb 39260 40052 36387 37179
  BB bb 39266 40052 36393 37179   BB bb 39341 40052 36468 37179
  BB bb 39347 40052 36474 37179   BB bb 39419 40052 36546 37179
  CC aa 31953 32712 31953 32712   CC aa 32105 32712 32105 32712
  CC aa 32282 32712 32282 32712   CC aa 32554 32712 32554 32712
  CC bb 31890 32712 29936 30758   CC bb 32366 32712 30412 30758
  DD aa 28745 29590 28745 29590   DD aa 29334 29590 29334 29590
  DD aa 29366 29590 29366 29590   DD bb 28631 29590 27306 28265
  DD bb 28796 29590 27471 28265   DD bb 28874 29590 27549 28265
  DD bb 29352 29590 28027 28265   EE aa 24781 25558 24781 25558
  EE aa 25445 25558 25445 25558   EE bb 24790 25558 23900 24668
  EE bb 24929 25558 24039 24668   EE bb 25306 25558 24416 24668
  FF aa 22349 23019 22349 23019   FF aa 22352 23019 22352 23019
  FF aa 22401 23019 22401 23019   FF aa 22811 23019 22811 23019
  FF bb 22081 23019 19918 20856   FF bb 22149 23019 19986 20856
  FF bb 22293 23019 20130 20856   FF bb 22445 23019 20282 20856
  FF bb 22724 23019 20561 20856   FF bb 22917 23019 20754 20856
  GG aa 16717 17351 16717 17351   GG aa 16871 17351 16871 17351
  GG aa 17016 17351 17016 17351   GG aa 17203 17351 17203 17351
  GG bb 16413 17351 14816 15754   GG bb 16422 17351 14825 15754
  GG bb 16507 17351 14910 15754   GG bb 17191 17351 15594 15754
  HH aa 11904 12883 11904 12883   HH aa 12093 12883 12093 12883
  HH aa 12403 12883 12403 12883   HH bb 11920 12883 9671 10634
  HH bb 12153 12883 9904 10634   HH bb 12200 12883 9951 10634
  HH bb 12528 12883 10279 10634   HH bb 12553 12883 10304 10634
  HH bb 12750 12883 10501 10634   II aa 6788 7440 6788 7440
  II aa 7042 7440 7042 7440   II bb 6635 7440 5585 6390
  II bb 6769 7440 5719 6390   II bb 6997 7440 5947 6390
  II bb 7019 7440 5969 6390   II bb 7190 7440 6140 6390
  JJ aa 2901 3800 2901 3800   JJ aa 3032 3800 3032 3800
  JJ aa 3566 3800 3566 3800   JJ aa 3687 3800 3687 3800
  JJ bb 2961 3800 947 1786   JJ bb 3446 3800 1432 1786
  JJ bb 3464 3800 1450 1786   JJ bb 3543 3800 1529 1786}

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

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

do_execsql_test 1.15.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.15.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 979   AA aa 979   AA aa 979   AA aa 979   AA bb 979   AA bb 979
  AA bb 979   AA bb 979   BB aa 979   BB aa 979   BB aa 979   BB aa 979
  BB aa 979   BB aa 979   BB bb 979   BB bb 979   BB bb 979   BB bb 979
  BB bb 979   BB bb 979   CC aa 979   CC aa 979   CC aa 979   CC aa 979
  CC bb 979   CC bb 979   DD aa 979   DD aa 979   DD aa 979   DD bb 979
  DD bb 979   DD bb 979   DD bb 979   EE aa 979   EE aa 979   EE bb 979
  EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979
  FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979
  GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979
  GG bb 979   GG bb 979   HH aa 979   HH aa 979   HH aa 979   HH bb 963
  HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 899
  II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899
  JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839
  JJ bb 839   JJ bb 839}

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

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

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

do_execsql_test 1.15.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN CURRENT ROW         AND UNBOUNDED FOLLOWING )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 43803 44737 43803 44737   AA aa 43826 44737 43826 44737
  AA aa 44498 44737 44498 44737   AA aa 44514 44737 44514 44737
  AA bb 43867 44737 41560 42430   AA bb 44110 44737 41803 42430
  AA bb 44165 44737 41858 42430   AA bb 44428 44737 42121 42430
  BB aa 39290 40052 39290 40052   BB aa 39392 40052 39392 40052
  BB aa 39640 40052 39640 40052   BB aa 39653 40052 39653 40052
  BB aa 39659 40052 39659 40052   BB aa 39805 40052 39805 40052
  BB bb 39212 40052 36339 37179   BB bb 39260 40052 36387 37179
  BB bb 39266 40052 36393 37179   BB bb 39341 40052 36468 37179
  BB bb 39347 40052 36474 37179   BB bb 39419 40052 36546 37179
  CC aa 31953 32712 31953 32712   CC aa 32105 32712 32105 32712
  CC aa 32282 32712 32282 32712   CC aa 32554 32712 32554 32712
  CC bb 31890 32712 29936 30758   CC bb 32366 32712 30412 30758
  DD aa 28745 29590 28745 29590   DD aa 29334 29590 29334 29590
  DD aa 29366 29590 29366 29590   DD bb 28631 29590 27306 28265
  DD bb 28796 29590 27471 28265   DD bb 28874 29590 27549 28265
  DD bb 29352 29590 28027 28265   EE aa 24781 25558 24781 25558
  EE aa 25445 25558 25445 25558   EE bb 24790 25558 23900 24668
  EE bb 24929 25558 24039 24668   EE bb 25306 25558 24416 24668
  FF aa 22349 23019 22349 23019   FF aa 22352 23019 22352 23019
  FF aa 22401 23019 22401 23019   FF aa 22811 23019 22811 23019
  FF bb 22081 23019 19918 20856   FF bb 22149 23019 19986 20856
  FF bb 22293 23019 20130 20856   FF bb 22445 23019 20282 20856
  FF bb 22724 23019 20561 20856   FF bb 22917 23019 20754 20856
  GG aa 16717 17351 16717 17351   GG aa 16871 17351 16871 17351
  GG aa 17016 17351 17016 17351   GG aa 17203 17351 17203 17351
  GG bb 16413 17351 14816 15754   GG bb 16422 17351 14825 15754
  GG bb 16507 17351 14910 15754   GG bb 17191 17351 15594 15754
  HH aa 11904 12883 11904 12883   HH aa 12093 12883 12093 12883
  HH aa 12403 12883 12403 12883   HH bb 11920 12883 9671 10634
  HH bb 12153 12883 9904 10634   HH bb 12200 12883 9951 10634
  HH bb 12528 12883 10279 10634   HH bb 12553 12883 10304 10634
  HH bb 12750 12883 10501 10634   II aa 6788 7440 6788 7440
  II aa 7042 7440 7042 7440   II bb 6635 7440 5585 6390
  II bb 6769 7440 5719 6390   II bb 6997 7440 5947 6390
  II bb 7019 7440 5969 6390   II bb 7190 7440 6140 6390
  JJ aa 2901 3800 2901 3800   JJ aa 3032 3800 3032 3800
  JJ aa 3566 3800 3566 3800   JJ aa 3687 3800 3687 3800
  JJ bb 2961 3800 947 1786   JJ bb 3446 3800 1432 1786
  JJ bb 3464 3800 1450 1786   JJ bb 3543 3800 1529 1786}

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

do_execsql_test 1.16.2 {
  SELECT a, b, sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 2307   AA aa 2307   AA aa 2307   AA aa 2307   AA bb 2378   AA bb 2378
  AA bb 2378   AA bb 2378   BB aa 2873   BB aa 2873   BB aa 2873   BB aa 2873
  BB aa 2873   BB aa 2873   BB bb 4467   BB bb 4467   BB bb 4467   BB bb 4467
  BB bb 4467   BB bb 4467   CC aa 1954   CC aa 1954   CC aa 1954   CC aa 1954
  CC bb 1168   CC bb 1168   DD aa 1325   DD aa 1325   DD aa 1325   DD bb 2707
  DD bb 2707   DD bb 2707   DD bb 2707   EE aa 890   EE aa 890   EE bb 1649
  EE bb 1649   EE bb 1649   FF aa 2163   FF aa 2163   FF aa 2163   FF aa 2163
  FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505   FF bb 3505
  GG aa 1597   GG aa 1597   GG aa 1597   GG aa 1597   GG bb 2871   GG bb 2871
  GG bb 2871   GG bb 2871   HH aa 2249   HH aa 2249   HH aa 2249   HH bb 3194
  HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   HH bb 3194   II aa 1050
  II aa 1050   II bb 2590   II bb 2590   II bb 2590   II bb 2590   II bb 2590
  JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ aa 2014   JJ bb 1786   JJ bb 1786
  JJ bb 1786   JJ bb 1786}

do_execsql_test 1.16.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.16.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 934   AA aa 934   AA aa 934   AA aa 934   AA bb 870   AA bb 870
  AA bb 870   AA bb 870   BB aa 762   BB aa 762   BB aa 762   BB aa 762
  BB aa 762   BB aa 762   BB bb 840   BB bb 840   BB bb 840   BB bb 840
  BB bb 840   BB bb 840   CC aa 759   CC aa 759   CC aa 759   CC aa 759
  CC bb 822   CC bb 822   DD aa 845   DD aa 845   DD aa 845   DD bb 959
  DD bb 959   DD bb 959   DD bb 959   EE aa 777   EE aa 777   EE bb 768
  EE bb 768   EE bb 768   FF aa 670   FF aa 670   FF aa 670   FF aa 670
  FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938   FF bb 938
  GG aa 634   GG aa 634   GG aa 634   GG aa 634   GG bb 938   GG bb 938
  GG bb 938   GG bb 938   HH aa 979   HH aa 979   HH aa 979   HH bb 963
  HH bb 963   HH bb 963   HH bb 963   HH bb 963   HH bb 963   II aa 652
  II aa 652   II bb 805   II bb 805   II bb 805   II bb 805   II bb 805
  JJ aa 899   JJ aa 899   JJ aa 899   JJ aa 899   JJ bb 839   JJ bb 839
  JJ bb 839   JJ bb 839}

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

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

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

do_execsql_test 1.16.8 {
  SELECT a, b, 
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING ),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING  EXCLUDE CURRENT ROW),
      sum(c) OVER (ORDER BY a,b  GROUPS BETWEEN 0 FOLLOWING         AND 0 FOLLOWING )
    FROM t3 ORDER BY 1, 2, 3;
} {AA aa 3751 4685 1373 2307   AA aa 3774 4685 1396 2307
  AA aa 4446 4685 2068 2307   AA aa 4462 4685 2084 2307
  AA bb 3815 4685 1508 2378   AA bb 4058 4685 1751 2378
  AA bb 4113 4685 1806 2378   AA bb 4376 4685 2069 2378
  BB aa 6578 7340 2111 2873   BB aa 6680 7340 2213 2873
  BB aa 6928 7340 2461 2873   BB aa 6941 7340 2474 2873
  BB aa 6947 7340 2480 2873   BB aa 7093 7340 2626 2873
  BB bb 6500 7340 3627 4467   BB bb 6548 7340 3675 4467
  BB bb 6554 7340 3681 4467   BB bb 6629 7340 3756 4467
  BB bb 6635 7340 3762 4467   BB bb 6707 7340 3834 4467
  CC aa 2363 3122 1195 1954   CC aa 2515 3122 1347 1954
  CC aa 2692 3122 1524 1954   CC aa 2964 3122 1796 1954
  CC bb 2300 3122 346 1168   CC bb 2776 3122 822 1168
  DD aa 3187 4032 480 1325   DD aa 3776 4032 1069 1325
  DD aa 3808 4032 1101 1325   DD bb 3073 4032 1748 2707
  DD bb 3238 4032 1913 2707   DD bb 3316 4032 1991 2707
  DD bb 3794 4032 2469 2707   EE aa 1762 2539 113 890
  EE aa 2426 2539 777 890   EE bb 1771 2539 881 1649
  EE bb 1910 2539 1020 1649   EE bb 2287 2539 1397 1649
  FF aa 4998 5668 1493 2163   FF aa 5001 5668 1496 2163
  FF aa 5050 5668 1545 2163   FF aa 5460 5668 1955 2163
  FF bb 4730 5668 2567 3505   FF bb 4798 5668 2635 3505
  FF bb 4942 5668 2779 3505   FF bb 5094 5668 2931 3505
  FF bb 5373 5668 3210 3505   FF bb 5566 5668 3403 3505
  GG aa 3834 4468 963 1597   GG aa 3988 4468 1117 1597
  GG aa 4133 4468 1262 1597   GG aa 4320 4468 1449 1597
  GG bb 3530 4468 1933 2871   GG bb 3539 4468 1942 2871
  GG bb 3624 4468 2027 2871   GG bb 4308 4468 2711 2871
  HH aa 4464 5443 1270 2249   HH aa 4653 5443 1459 2249
  HH aa 4963 5443 1769 2249   HH bb 4480 5443 2231 3194
  HH bb 4713 5443 2464 3194   HH bb 4760 5443 2511 3194
  HH bb 5088 5443 2839 3194   HH bb 5113 5443 2864 3194
  HH bb 5310 5443 3061 3194   II aa 2988 3640 398 1050
  II aa 3242 3640 652 1050   II bb 2835 3640 1785 2590
  II bb 2969 3640 1919 2590   II bb 3197 3640 2147 2590
  II bb 3219 3640 2169 2590   II bb 3390 3640 2340 2590
  JJ aa 2901 3800 1115 2014   JJ aa 3032 3800 1246 2014
  JJ aa 3566 3800 1780 2014   JJ aa 3687 3800 1901 2014
  JJ bb 2961 3800 947 1786   JJ bb 3446 3800 1432 1786
  JJ bb 3464 3800 1450 1786   JJ bb 3543 3800 1529 1786}

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

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

do_execsql_test 1.17.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND 0 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

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

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

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

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

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

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

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

do_execsql_test 1.18.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

do_execsql_test 1.18.4 {
  SELECT a, b, max(c) OVER (ORDER BY a,b  GROUPS BETWEEN 1 FOLLOWING         AND 5 FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 870   AA aa 870   AA aa 870   AA aa 870   AA bb 845   AA bb 845
  AA bb 845   AA bb 845   BB aa 959   BB aa 959   BB aa 959   BB aa 959
  BB aa 959   BB aa 959   BB bb 959   BB bb 959   BB bb 959   BB bb 959
  BB bb 959   BB bb 959   CC aa 959   CC aa 959   CC aa 959   CC aa 959
  CC bb 959   CC bb 959   DD aa 959   DD aa 959   DD aa 959   DD bb 938
  DD bb 938   DD bb 938   DD bb 938   EE aa 938   EE aa 938   EE bb 979
  EE bb 979   EE bb 979   FF aa 979   FF aa 979   FF aa 979   FF aa 979
  FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979   FF bb 979
  GG aa 979   GG aa 979   GG aa 979   GG aa 979   GG bb 979   GG bb 979
  GG bb 979   GG bb 979   HH aa 963   HH aa 963   HH aa 963   HH bb 899
  HH bb 899   HH bb 899   HH bb 899   HH bb 899   HH bb 899   II aa 899
  II aa 899   II bb 899   II bb 899   II bb 899   II bb 899   II bb 899
  JJ aa 839   JJ aa 839   JJ aa 839   JJ aa 839   JJ bb {}   JJ bb {}
  JJ bb {}   JJ bb {}}

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

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

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

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

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

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

do_execsql_test 1.19.3 {
  SELECT a, b, rank() OVER (ORDER BY a  GROUPS BETWEEN 1 FOLLOWING         AND UNBOUNDED FOLLOWING ) FROM t3 ORDER BY 1, 2, 3;
} {AA aa 1   AA aa 1   AA aa 1   AA aa 1   AA bb 1   AA bb 1   AA bb 1
  AA bb 1   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9   BB aa 9
  BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   BB bb 9   CC aa 21
  CC aa 21   CC aa 21   CC aa 21   CC bb 21   CC bb 21   DD aa 27   DD aa 27
  DD aa 27   DD bb 27   DD bb 27   DD bb 27   DD bb 27   EE aa 34   EE aa 34
  EE bb 34   EE bb 34   EE bb 34   FF aa 39   FF aa 39   FF aa 39   FF aa 39
  FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   FF bb 39   GG aa 49
  GG aa 49   GG aa 49   GG aa 49   GG bb 49   GG bb 49   GG bb 49   GG bb 49
  HH aa 57   HH aa 57   HH aa 57   HH bb 57   HH bb 57   HH bb 57   HH bb 57
  HH bb 57   HH bb 57   II aa 66   II aa 66   II bb 66   II bb 66   II bb 66
  II bb 66   II bb 66   JJ aa 73   JJ aa 73   JJ aa 73   JJ aa 73   JJ bb 73
  JJ bb 73   JJ bb 73   JJ bb 73}

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

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

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

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

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

do_execsql_test 2.1.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE NO OTHERS 
    )
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17
  18   19   20   21   22   23   24   25   26   27   28   29   30   31   32
  33   34   35   36   37   38   39   40   41   42   43   44   45   46   47
  48   49   50   51   52   53   54   55   56   57   58   59   60   61   62
  63   64   65   66   67   68   69   70   71   72   73   74   75   76   77
  78   79   80}

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

do_execsql_test 2.1.3 {
  SELECT min(c) OVER win, max(c) OVER win, sum(c) OVER win FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW  EXCLUDE NO OTHERS 
    ) ORDER BY a, b, c;
} {102 223 1358   102 239 2293   102 911 38097   102 934 39960   102 309 4159
  102 572 10643   102 627 13069   102 870 35417   102 247 2540   102 393 6608
  102 399 7405   102 412 7817   102 660 16277   102 762 24077   102 633 14331
  102 705 19673   102 711 20384   102 786 27176   102 792 28758
  102 840 32858   102 158 767   102 430 8668   102 607 11824   102 759 23315
  102 346 5506   102 822 31179   102 224 1582   102 256 3298   102 845 34547
  102 238 2054   102 716 21100   102 794 29552   102 959 42795   102 113 215
  102 777 26390   102 252 3042   102 629 13698   102 768 25613   102 208 1135
  102 618 12442   102 667 16944   102 670 17614   102 102 102   102 295 3850
  102 574 11217   102 726 21826   102 870 36287   102 938 40898   102 148 609
  102 335 4824   102 480 9591   102 634 14965   102 160 927   102 844 33702
  102 929 39026   102 938 41836   102 480 10071   102 790 27966
  102 979 44737   102 133 461   102 330 4489   102 355 6215   102 683 18968
  102 730 22556   102 963 43758   102 398 7006   102 652 15617   102 250 2790
  102 421 8238   102 443 9111   102 671 18285   102 805 30357   102 113 328
  102 234 1816   102 768 24845   102 899 37186   102 257 3555   102 336 5160
  102 354 5860   102 839 32018}

do_execsql_test 2.2.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE CURRENT ROW 
    )
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17
  18   19   20   21   22   23   24   25   26   27   28   29   30   31   32
  33   34   35   36   37   38   39   40   41   42   43   44   45   46   47
  48   49   50   51   52   53   54   55   56   57   58   59   60   61   62
  63   64   65   66   67   68   69   70   71   72   73   74   75   76   77
  78   79   80}

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

do_execsql_test 2.2.3 {
  SELECT min(c) OVER win, max(c) OVER win, sum(c) OVER win FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW  EXCLUDE CURRENT ROW 
    ) ORDER BY a, b, c;
} {102 208 1135   102 238 2054   102 899 37186   102 929 39026   102 295 3850
  102 480 10071   102 618 12442   102 845 34547   102 239 2293   102 355 6215
  102 398 7006   102 399 7405   102 652 15617   102 759 23315   102 629 13698
  102 683 18968   102 705 19673   102 777 26390   102 790 27966
  102 839 32018   102 148 609   102 421 8238   102 574 11217   102 730 22556
  102 336 5160   102 805 30357   102 223 1358   102 252 3042   102 844 33702
  102 234 1816   102 711 20384   102 792 28758   102 938 41836   102 102 102
  102 768 25613   102 250 2790   102 627 13069   102 768 24845   102 160 927
  102 607 11824   102 660 16277   102 667 16944   {} {} {}   102 257 3555
  102 572 10643   102 716 21100   102 870 35417   102 934 39960   102 133 461
  102 330 4489   102 443 9111   102 633 14331   102 158 767   102 840 32858
  102 911 38097   102 938 40898   102 480 9591   102 786 27176
  102 963 43758   102 113 328   102 309 4159   102 354 5860   102 671 18285
  102 726 21826   102 959 42795   102 393 6608   102 634 14965   102 247 2540
  102 412 7817   102 430 8668   102 670 17614   102 794 29552   102 113 215
  102 224 1582   102 762 24077   102 870 36287   102 256 3298   102 335 4824
  102 346 5506   102 822 31179}

do_execsql_test 2.3.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE GROUP 
    )
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17
  18   19   20   21   22   23   24   25   26   27   28   29   30   31   32
  33   34   35   36   37   38   39   40   41   42   43   44   45   46   47
  48   49   50   51   52   53   54   55   56   57   58   59   60   61   62
  63   64   65   66   67   68   69   70   71   72   73   74   75   76   77
  78   79   80}

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

do_execsql_test 2.3.3 {
  SELECT min(c) OVER win, max(c) OVER win, sum(c) OVER win FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW  EXCLUDE GROUP 
    ) ORDER BY a, b, c;
} {102 208 1135   102 238 2054   102 899 37186   102 929 39026   102 295 3850
  102 480 10071   102 618 12442   102 845 34547   102 239 2293   102 355 6215
  102 398 7006   102 399 7405   102 652 15617   102 759 23315   102 629 13698
  102 683 18968   102 705 19673   102 777 26390   102 790 27966
  102 839 32018   102 148 609   102 421 8238   102 574 11217   102 730 22556
  102 336 5160   102 805 30357   102 223 1358   102 252 3042   102 844 33702
  102 234 1816   102 711 20384   102 792 28758   102 938 41836   102 102 102
  102 768 25613   102 250 2790   102 627 13069   102 768 24845   102 160 927
  102 607 11824   102 660 16277   102 667 16944   {} {} {}   102 257 3555
  102 572 10643   102 716 21100   102 870 35417   102 934 39960   102 133 461
  102 330 4489   102 443 9111   102 633 14331   102 158 767   102 840 32858
  102 911 38097   102 938 40898   102 480 9591   102 786 27176
  102 963 43758   102 113 328   102 309 4159   102 354 5860   102 671 18285
  102 726 21826   102 959 42795   102 393 6608   102 634 14965   102 247 2540
  102 412 7817   102 430 8668   102 670 17614   102 794 29552   102 113 215
  102 224 1582   102 762 24077   102 870 36287   102 256 3298   102 335 4824
  102 346 5506   102 822 31179}

do_execsql_test 2.4.1 {
  SELECT row_number() OVER win 
    FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  EXCLUDE TIES 
    )
} {1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17
  18   19   20   21   22   23   24   25   26   27   28   29   30   31   32
  33   34   35   36   37   38   39   40   41   42   43   44   45   46   47
  48   49   50   51   52   53   54   55   56   57   58   59   60   61   62
  63   64   65   66   67   68   69   70   71   72   73   74   75   76   77
  78   79   80}

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

do_execsql_test 2.4.3 {
  SELECT min(c) OVER win, max(c) OVER win, sum(c) OVER win FROM t3
    WINDOW win AS (
      ORDER BY c, b, a
      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW  EXCLUDE TIES 
    ) ORDER BY a, b, c;
} {102 223 1358   102 239 2293   102 911 38097   102 934 39960   102 309 4159
  102 572 10643   102 627 13069   102 870 35417   102 247 2540   102 393 6608
  102 399 7405   102 412 7817   102 660 16277   102 762 24077   102 633 14331
  102 705 19673   102 711 20384   102 786 27176   102 792 28758
  102 840 32858   102 158 767   102 430 8668   102 607 11824   102 759 23315
  102 346 5506   102 822 31179   102 224 1582   102 256 3298   102 845 34547
  102 238 2054   102 716 21100   102 794 29552   102 959 42795   102 113 215
  102 777 26390   102 252 3042   102 629 13698   102 768 25613   102 208 1135
  102 618 12442   102 667 16944   102 670 17614   102 102 102   102 295 3850
  102 574 11217   102 726 21826   102 870 36287   102 938 40898   102 148 609
  102 335 4824   102 480 9591   102 634 14965   102 160 927   102 844 33702
  102 929 39026   102 938 41836   102 480 10071   102 790 27966
  102 979 44737   102 133 461   102 330 4489   102 355 6215   102 683 18968
  102 730 22556   102 963 43758   102 398 7006   102 652 15617   102 250 2790
  102 421 8238   102 443 9111   102 671 18285   102 805 30357   102 113 328
  102 234 1816   102 768 24845   102 899 37186   102 257 3555   102 336 5160
  102 354 5860   102 839 32018}

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

do_execsql_test 3.0 {
  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(a REAL, b INTEGER);
  INSERT INTO t1 VALUES
      (5, 10), (10, 20), (13, 26), (13, 26), 
      (15, 30), (20, 40), (22,80), (30, 90);
} {}

do_execsql_test 3.1 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 5 PRECEDING AND 5 FOLLOWING )
} {5 30   10 112   13 102   13 102   15 142   20 150   22 120   30 90}

do_execsql_test 3.2 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 10 PRECEDING AND 5 PRECEDING )
} {5 {}   10 10   13 10   13 10   15 30   20 102   22 82   30 120}

do_execsql_test 3.3 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING )
} {5 {}   10 52   13 30   13 30   15 {}   20 80   22 {}   30 {}}

do_execsql_test 3.4 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 5 PRECEDING AND 5 FOLLOWING )
} {30 90   22 120   20 150   15 142   13 102   13 102   10 112   5 30}

do_execsql_test 3.5 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 10 PRECEDING AND 5 PRECEDING )
} {30 {}   22 90   20 90   15 120   13 120   13 120   10 70   5 102}

do_execsql_test 3.6 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 2 FOLLOWING AND 3 FOLLOWING )
} {30 {}   22 40   20 {}   15 52   13 20   13 20   10 {}   5 {}}

do_execsql_test 3.7 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 5.1 PRECEDING AND 5.3 FOLLOWING )
} {5 30   10 112   13 102   13 102   15 142   20 150   22 120   30 90}

do_execsql_test 3.8 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 10.2 PRECEDING AND 5.4 PRECEDING )
} {5 {}   10 {}   13 10   13 10   15 10   20 72   22 82   30 120}

do_execsql_test 3.9 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE BETWEEN 2.6 FOLLOWING AND 3.5 FOLLOWING )
} {5 {}   10 52   13 {}   13 {}   15 {}   20 {}   22 {}   30 {}}

do_execsql_test 3.10 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 5.7 PRECEDING AND 5.8 FOLLOWING )
} {30 90   22 120   20 150   15 142   13 102   13 102   10 112   5 30}

do_execsql_test 3.11 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND 5.9 PRECEDING )
} {30 {}   22 90   20 90   15 170   13 210   13 210   10 210   5 292}

do_execsql_test 3.12 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a DESC RANGE BETWEEN 2.1 FOLLOWING AND UNBOUNDED FOLLOWING )
} {30 232   22 112   20 112   15 30   13 30   13 30   10 10   5 {}}

do_execsql_test 3.13 {
  SELECT CAST(a AS INTEGER), sum(b) OVER win FROM t1 WINDOW win AS ( ORDER BY a RANGE 5.1 PRECEDING )
} {5 10   10 30   13 72   13 72   15 102   20 70   22 120   30 90}

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

do_execsql_test 4.0 {
  DROP TABLE IF EXISTS t1;
  CREATE TABLE t1(a INTEGER, b INTEGER);
  INSERT INTO t1 VALUES
    (NULL, 1), (NULL, 2), (NULL, 3), (10, 4), (10, 5);
} {}

do_execsql_test 4.1.1 {
  SELECT sum(b) OVER (
    ORDER BY a RANGE BETWEEN 5 PRECEDING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1;
} {6   6   6   9   9}

do_execsql_test 4.1.2 {
  SELECT sum(b) OVER (
    ORDER BY a DESC RANGE BETWEEN 5 PRECEDING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1;
} {6   6   6   9   9}

do_execsql_test 4.2.1 {
  SELECT sum(b) OVER (
    ORDER BY a RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS FIRST;
} {{}   {}   6   6   6}

do_execsql_test 4.2.2 {
  SELECT sum(b) OVER (
    ORDER BY a RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS LAST;
} {6   6   6   {}   {}}

do_execsql_test 4.2.3 {
  SELECT sum(b) OVER (
    ORDER BY a DESC RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS FIRST;
} {{}   {}   6   6   6}

do_execsql_test 4.2.4 {
  SELECT sum(b) OVER (
    ORDER BY a DESC RANGE BETWEEN 5 FOLLOWING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS LAST;
} {6   6   6   {}   {}}

do_execsql_test 4.3.1 {
  SELECT sum(b) OVER (
    ORDER BY a NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS FIRST;
} {6   6   6   15   15}

do_execsql_test 4.3.2 {
  SELECT sum(b) OVER (
    ORDER BY a NULLS LAST RANGE BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS LAST;
} {9   9   15   15   15}

do_execsql_test 4.4.1 {
  SELECT sum(b) OVER (
    ORDER BY a NULLS FIRST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS FIRST;
} {3   6   9   9   12}

do_execsql_test 4.4.2 {
  SELECT sum(b) OVER (
    ORDER BY a NULLS LAST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS LAST;
} {5   6   8   9   10}

do_execsql_test 4.4.3 {
  SELECT sum(b) OVER (
    ORDER BY a DESC NULLS LAST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS FIRST;
} {5   6   8   9   10}

do_execsql_test 4.4.4 {
  SELECT sum(b) OVER (
    ORDER BY a DESC NULLS LAST ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS LAST;
} {5   6   8   9   10}

do_execsql_test 4.5.1 {
  SELECT sum(b) OVER (
    ORDER BY a ASC  NULLS LAST RANGE BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS LAST;
} {9   9   15   15   15}

do_execsql_test 4.5.2 {
  SELECT sum(b) OVER (
    ORDER BY a DESC NULLS FIRST RANGE 
    BETWEEN UNBOUNDED PRECEDING AND 10 FOLLOWING
  ) FROM t1 ORDER BY 1 NULLS LAST;
} {6   6   6   15   15}

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

do_execsql_test 5.0 {
  INSERT INTO t3 VALUES
    (NULL, 'bb', 355), (NULL, 'cc', 158), (NULL, 'aa', 399), 
    ('JJ', NULL, 839), ('FF', NULL, 618), ('BB', NULL, 393), 
    (NULL, 'bb', 629), (NULL, NULL, 667), (NULL, NULL, 870);
} {}

do_execsql_test 5.1.1.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83}

do_execsql_test 5.1.1.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1}

do_execsql_test 5.1.2.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {899 113 9   899 113 9   899 113 9   899 113 9   899 113 9   899 113 9
  899 113 9   899 113 9   899 113 9   899 113 16   899 113 16   899 113 16
  899 113 16   899 113 16   899 113 16   899 113 16   979 102 44   979 102 44
  979 102 44   979 102 44   979 102 44   979 102 44   979 102 44   979 102 44
  979 102 44   979 102 44   979 102 44   979 102 49   979 102 49   979 102 49
  979 102 49   979 102 49   979 102 56   979 102 56   979 102 56   979 102 56
  979 102 56   979 102 56   979 102 56   979 102 62   979 102 62   979 102 62
  979 102 62   979 102 62   979 102 62   979 102 75   979 102 75   979 102 75
  979 102 75   979 102 75   979 102 75   979 102 75   979 102 75   979 102 75
  979 102 75   979 102 75   979 102 75   979 102 75   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 113 25   979 113 25   979 113 25   979 113 25   979 113 25   979 113 25
  979 113 25   979 113 25   979 113 25   979 113 33   979 113 33   979 113 33
  979 113 33   979 113 33   979 113 33   979 113 33   979 113 33}

do_execsql_test 5.1.2.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {2947 81 11   2947 81 11   2947 81 11   2947 81 11   2947 81 11   2947 81 11
  2947 81 11   2947 81 11   2947 81 11   5287 74 10   5287 74 10   5287 74 10
  5287 74 10   5287 74 10   5287 74 10   5287 74 10   8400 65 9   8400 65 9
  8400 65 9   8400 65 9   8400 65 9   8400 65 9   8400 65 9   8400 65 9
  8400 65 9   9664 57 8   9664 57 8   9664 57 8   9664 57 8   9664 57 8
  9664 57 8   9664 57 8   9664 57 8   10626 46 7   10626 46 7   10626 46 7
  10626 46 7   10626 46 7   10626 46 7   10626 46 7   10626 46 7   10626 46 7
  10626 46 7   10626 46 7   12145 41 6   12145 41 6   12145 41 6   12145 41 6
  12145 41 6   13949 34 5   13949 34 5   13949 34 5   13949 34 5   13949 34 5
  13949 34 5   13949 34 5   15315 28 4   15315 28 4   15315 28 4   15315 28 4
  15315 28 4   15315 28 4   18796 15 3   18796 15 3   18796 15 3   18796 15 3
  18796 15 3   18796 15 3   18796 15 3   18796 15 3   18796 15 3   18796 15 3
  18796 15 3   18796 15 3   18796 15 3   21105 7 2   21105 7 2   21105 7 2
  21105 7 2   21105 7 2   21105 7 2   21105 7 2   21105 7 2   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1}

do_execsql_test 5.1.3.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {777 113 5   777 113 5   777 113 5   777 113 5   777 113 5   805 250 7
  805 250 7   805 250 7   805 250 7   805 250 7   805 250 7   805 250 7
  822 158 6   822 158 6   822 158 6   822 158 6   822 158 6   822 158 6
  840 247 13   840 247 13   840 247 13   840 247 13   840 247 13   840 247 13
  840 247 13   840 247 13   840 247 13   840 247 13   840 247 13   840 247 13
  840 247 13   870 158 0   870 158 0   870 158 0   870 158 0   870 158 0
  870 158 0   899 113 9   899 113 9   899 113 9   899 113 9   899 113 9
  899 113 9   899 113 9   899 113 9   899 113 9   934 223 8   934 223 8
  934 223 8   934 223 8   934 223 8   934 223 8   934 223 8   934 223 8
  938 102 11   938 102 11   938 102 11   938 102 11   938 102 11   938 102 11
  938 102 11   938 102 11   938 102 11   938 102 11   938 102 11   938 148 8
  938 148 8   938 148 8   938 148 8   938 148 8   938 148 8   938 148 8
  938 148 8   959 224 7   959 224 7   959 224 7   959 224 7   959 224 7
  959 224 7   959 224 7   979 133 9   979 133 9   979 133 9   979 133 9
  979 133 9   979 133 9   979 133 9   979 133 9   979 133 9}

do_execsql_test 5.1.3.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {962 1 1   962 1 1   962 1 1   962 1 1   962 1 1   962 1 1   962 1 1
  962 1 1   962 1 1   962 1 1   962 1 1   1264 1 1   1264 1 1   1264 1 1
  1264 1 1   1264 1 1   1264 1 1   1264 1 1   1264 1 1   1366 1 1   1366 1 1
  1366 1 1   1366 1 1   1366 1 1   1366 1 1   1519 1 1   1519 1 1   1519 1 1
  1519 1 1   1519 1 1   1804 1 1   1804 1 1   1804 1 1   1804 1 1   1804 1 1
  1804 1 1   1804 1 1   2050 1 1   2050 1 1   2050 1 1   2050 1 1   2050 1 1
  2050 1 1   2309 1 1   2309 1 1   2309 1 1   2309 1 1   2309 1 1   2309 1 1
  2309 1 1   2309 1 1   2340 1 1   2340 1 1   2340 1 1   2340 1 1   2340 1 1
  2340 1 1   2340 1 1   2947 1 1   2947 1 1   2947 1 1   2947 1 1   2947 1 1
  2947 1 1   2947 1 1   2947 1 1   2947 1 1   3113 1 1   3113 1 1   3113 1 1
  3113 1 1   3113 1 1   3113 1 1   3113 1 1   3113 1 1   3113 1 1   3481 1 1
  3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1
  3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1}

do_execsql_test 5.1.4.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST GROUPS 6 PRECEDING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {870 158 0   870 158 0   870 158 0   870 158 0   870 158 0   870 158 0
  934 158 8   934 158 8   934 158 8   934 158 8   934 158 8   934 158 8
  934 158 8   934 158 8   934 158 21   934 158 21   934 158 21   934 158 21
  934 158 21   934 158 21   934 158 21   934 158 21   934 158 21   934 158 21
  934 158 21   934 158 21   934 158 21   934 158 27   934 158 27   934 158 27
  934 158 27   934 158 27   934 158 27   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 102 50   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 102 58   959 102 58   959 102 58   959 102 58
  959 102 58   959 102 58   959 102 58   959 102 58   959 113 39   959 113 39
  959 113 39   959 113 39   959 113 39   959 158 34   959 158 34   959 158 34
  959 158 34   959 158 34   959 158 34   959 158 34   979 102 53   979 102 53
  979 102 53   979 102 53   979 102 53   979 102 53   979 102 53   979 102 56
  979 102 56   979 102 56   979 102 56   979 102 56   979 102 56   979 102 56
  979 102 56   979 102 56   979 102 59   979 102 59   979 102 59   979 102 59
  979 102 59   979 102 59   979 102 59   979 102 59   979 102 59}

do_execsql_test 5.1.4.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST GROUPS 6 PRECEDING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {2050 1 1   2050 1 1   2050 1 1   2050 1 1   2050 1 1   2050 1 1   4359 7 2
  4359 7 2   4359 7 2   4359 7 2   4359 7 2   4359 7 2   4359 7 2   4359 7 2
  7840 15 3   7840 15 3   7840 15 3   7840 15 3   7840 15 3   7840 15 3
  7840 15 3   7840 15 3   7840 15 3   7840 15 3   7840 15 3   7840 15 3
  7840 15 3   9206 28 4   9206 28 4   9206 28 4   9206 28 4   9206 28 4
  9206 28 4   11010 34 5   11010 34 5   11010 34 5   11010 34 5   11010 34 5
  11010 34 5   11010 34 5   12368 74 10   12368 74 10   12368 74 10
  12368 74 10   12368 74 10   12368 74 10   12368 74 10   12529 41 6
  12529 41 6   12529 41 6   12529 41 6   12529 41 6   12705 57 8   12705 57 8
  12705 57 8   12705 57 8   12705 57 8   12705 57 8   12705 57 8   12705 57 8
  13491 46 7   13491 46 7   13491 46 7   13491 46 7   13491 46 7   13491 46 7
  13491 46 7   13491 46 7   13491 46 7   13491 46 7   13491 46 7   13509 65 9
  13509 65 9   13509 65 9   13509 65 9   13509 65 9   13509 65 9   13509 65 9
  13509 65 9   13509 65 9   13949 81 11   13949 81 11   13949 81 11
  13949 81 11   13949 81 11   13949 81 11   13949 81 11   13949 81 11
  13949 81 11}

do_execsql_test 5.1.5.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 2   113 113 2   133 133 1   148 148 1   160 158 2
  160 158 2   160 158 2   208 208 1   224 223 2   224 223 2   239 234 3
  239 234 3   239 234 3   252 247 3   257 247 5   257 247 5   257 250 4
  257 252 3   295 295 1   309 309 1   336 330 3   336 330 3   336 330 3
  346 346 1   355 354 2   355 354 2   355 354 2   399 393 4   399 393 4
  399 393 4   399 393 4   399 393 4   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 2   480 480 2   574 572 2   574 572 2   607 607 1
  618 618 2   618 618 2   634 627 4   634 627 4   634 627 4   634 627 4
  634 629 3   652 652 1   667 660 2   671 667 3   671 667 3   671 667 3
  671 667 3   683 683 1   711 705 2   716 705 3   716 711 2   730 726 2
  730 726 2   762 759 2   768 759 4   768 762 3   768 762 3   777 777 1
  792 786 3   794 786 4   794 786 4   794 790 3   805 805 1   822 822 1
  845 839 5   845 839 5   845 839 5   845 839 5   845 839 5   870 870 2
  870 870 2   870 870 2   899 899 1   911 911 1   934 929 2   938 929 4
  938 934 3   938 934 3   963 959 2   963 959 2   979 979 1}

do_execsql_test 5.1.5.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 25 23   {} 34 29
  {} 36 31   {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 43 37   {} 43 37
  {} 50 42   {} 60 51   {} 61 52   {} 64 55   {} 64 55   {} 67 57   {} 68 58
  {} 69 59   {} 70 60   {} 72 62   {} 78 67   {} 78 67   {} 78 67   {} 85 72
  {} 85 72   133 4 3   223 10 8   223 11 9   226 2 2   226 2 2   239 12 10
  239 13 11   239 14 12   247 15 13   257 18 16   257 19 17   295 20 18
  309 21 19   335 22 20   335 23 21   335 24 22   421 35 30   443 37 32
  504 16 14   504 17 15   607 42 36   683 56 47   710 26 24   710 27 25
  710 27 25   711 59 50   759 62 53   759 63 54   777 66 56   805 71 61
  899 81 68   911 82 69   929 83 70   929 84 71   979 89 75   1334 51 43
  1416 57 48   1416 58 49   1584 29 26   1584 29 26   1584 31 27   1584 32 28
  1584 32 28   1891 49 41   1922 87 73   1922 88 74   2005 52 44   2005 52 44
  2005 54 45   2005 55 46   2518 45 38   2518 46 39   2518 46 39   2518 48 40
  2523 73 63   2523 73 63   2523 75 64   2523 76 65   2523 77 66}

do_execsql_test 5.1.6.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 2   113 113 2   133 133 1   148 148 1   158 158 1
  158 158 1   160 160 1   208 208 1   223 223 1   224 224 1   234 234 1
  238 238 1   239 239 1   247 247 1   250 250 1   252 252 1   256 256 1
  257 257 1   295 295 1   309 309 1   330 330 1   335 335 1   336 336 1
  346 346 1   354 354 1   355 355 1   355 355 1   393 393 2   393 393 2
  398 398 1   399 399 1   399 399 1   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 2   480 480 2   572 572 1   574 574 1   607 607 1
  618 618 2   618 618 2   627 627 1   629 629 1   629 629 1   633 633 1
  634 634 1   652 652 1   660 660 1   667 667 1   667 667 1   670 670 1
  671 671 1   683 683 1   705 705 1   711 711 1   716 716 1   726 726 1
  730 730 1   759 759 1   762 762 1   768 768 2   768 768 2   777 777 1
  786 786 1   790 790 1   792 792 1   794 794 1   805 805 1   822 822 1
  839 839 2   839 839 2   840 840 1   844 844 1   845 845 1   870 870 2
  870 870 2   870 870 2   899 899 1   911 911 1   929 929 1   934 934 1
  938 938 2   938 938 2   959 959 1   963 963 1   979 979 1}

do_execsql_test 5.1.6.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 11 9   {} 12 10
  {} 13 11   {} 16 14   {} 17 15   {} 18 16   {} 22 20   {} 24 22   {} 25 23
  {} 26 24   {} 31 27   {} 34 29   {} 36 31   {} 38 33   {} 38 33   {} 40 34
  {} 41 35   {} 43 37   {} 43 37   {} 49 41   {} 50 42   {} 51 43   {} 54 45
  {} 59 50   {} 60 51   {} 61 52   {} 63 54   {} 64 55   {} 64 55   {} 67 57
  {} 68 58   {} 69 59   {} 70 60   {} 72 62   {} 75 64   {} 76 65   {} 78 67
  {} 78 67   {} 78 67   {} 84 71   {} 85 72   {} 85 72   133 4 3   223 10 8
  226 2 2   226 2 2   239 14 12   247 15 13   257 19 17   295 20 18
  309 21 19   335 23 21   421 35 30   443 37 32   607 42 36   627 45 38
  633 48 40   671 55 46   683 56 47   705 57 48   710 27 25   710 27 25
  711 58 49   759 62 53   777 66 56   786 29 26   786 29 26   798 32 28
  798 32 28   805 71 61   845 77 66   899 81 68   911 82 69   929 83 70
  959 87 73   963 88 74   979 89 75   1258 46 39   1258 46 39   1334 52 44
  1334 52 44   1678 73 63   1678 73 63}

do_execsql_test 5.1.7.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 113 81   979 113 82   979 133 80   979 148 79   979 158 77
  979 158 78   979 160 77   979 208 76   979 223 75   979 224 74   979 234 73
  979 238 72   979 239 71   979 247 70   979 250 69   979 252 68   979 256 67
  979 257 66   979 295 65   979 309 64   979 330 63   979 335 62   979 336 61
  979 346 60   979 354 59   979 355 58   979 355 58   979 393 56   979 393 57
  979 398 55   979 399 54   979 399 54   979 412 53   979 421 52   979 430 51
  979 443 50   979 480 48   979 480 49   979 572 47   979 574 46   979 607 45
  979 618 43   979 618 44   979 627 42   979 629 41   979 629 41   979 633 40
  979 634 39   979 652 38   979 660 37   979 667 36   979 667 36   979 670 35
  979 671 34   979 683 33   979 705 32   979 711 31   979 716 30   979 726 29
  979 730 28   979 759 27   979 762 26   979 768 24   979 768 25   979 777 23
  979 786 22   979 790 21   979 792 20   979 794 19   979 805 18   979 822 17
  979 839 15   979 839 16   979 840 14   979 844 13   979 845 12   979 870 10
  979 870 11   979 870 11   979 899 9   979 911 8   979 929 7}

do_execsql_test 5.1.7.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {3830 89 89   4741 88 88   5640 84 84   5640 85 85   5640 86 86   5640 87 87
  6485 81 81   6485 82 82   6485 83 83   7324 80 80   8163 78 78   8163 79 79
  8968 73 73   8968 74 74   8968 75 75   8968 76 76   8968 77 77   9745 69 69
  9745 70 70   9745 71 71   9745 72 72   10504 65 65   10504 66 66
  10504 67 67   10504 68 68   11215 64 64   11920 63 63   12603 62 62
  13274 60 60   13274 61 61   13941 59 59   14608 55 55   14608 56 56
  14608 57 57   14608 58 58   15241 54 54   15870 53 53   16499 52 52
  17126 49 49   17126 50 50   17126 51 51   17733 44 44   17733 45 45
  17733 46 46   17733 47 47   17733 48 48   18176 42 42   18176 43 43
  18597 40 40   18597 41 41   18996 39 39   19395 37 37   19395 38 38
  19788 36 36   20181 35 35   20536 34 34   20891 30 30   20891 31 31
  20891 32 32   20891 33 33   21226 28 28   21226 29 29   21535 27 27
  21830 26 26   22087 22 22   22087 23 23   22087 24 24   22087 25 25
  22334 21 21   22573 17 17   22573 18 18   22573 19 19   22573 20 20
  22796 11 11   22796 12 12   22796 13 13   22796 14 14   22796 15 15
  22796 16 16   22929 10 10   23042 9 9   23155 1 1   23155 2 2   23155 3 3
  23155 4 4   23155 5 5   23155 6 6   23155 7 7   23155 8 8}

do_execsql_test 5.1.8.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83}

do_execsql_test 5.1.8.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1}

do_execsql_test 5.1.9.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {870 158 0   870 158 0   870 158 0   870 158 0   870 158 0   870 158 0
  899 113 9   899 113 9   899 113 9   899 113 9   899 113 9   899 113 9
  899 113 9   899 113 9   899 113 9   899 113 16   899 113 16   899 113 16
  899 113 16   899 113 16   899 113 16   899 113 16   979 102 44   979 102 44
  979 102 44   979 102 44   979 102 44   979 102 44   979 102 44   979 102 44
  979 102 44   979 102 44   979 102 44   979 102 49   979 102 49   979 102 49
  979 102 49   979 102 49   979 102 56   979 102 56   979 102 56   979 102 56
  979 102 56   979 102 56   979 102 56   979 102 62   979 102 62   979 102 62
  979 102 62   979 102 62   979 102 62   979 102 75   979 102 75   979 102 75
  979 102 75   979 102 75   979 102 75   979 102 75   979 102 75   979 102 75
  979 102 75   979 102 75   979 102 75   979 102 75   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 113 25   979 113 25   979 113 25   979 113 25   979 113 25   979 113 25
  979 113 25   979 113 25   979 113 25   979 113 33   979 113 33   979 113 33
  979 113 33   979 113 33   979 113 33   979 113 33   979 113 33}

do_execsql_test 5.1.9.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {2050 84 11   2050 84 11   2050 84 11   2050 84 11   2050 84 11   2050 84 11
  4997 75 10   4997 75 10   4997 75 10   4997 75 10   4997 75 10   4997 75 10
  4997 75 10   4997 75 10   4997 75 10   7337 68 9   7337 68 9   7337 68 9
  7337 68 9   7337 68 9   7337 68 9   7337 68 9   10450 59 8   10450 59 8
  10450 59 8   10450 59 8   10450 59 8   10450 59 8   10450 59 8   10450 59 8
  10450 59 8   11714 51 7   11714 51 7   11714 51 7   11714 51 7   11714 51 7
  11714 51 7   11714 51 7   11714 51 7   12676 40 6   12676 40 6   12676 40 6
  12676 40 6   12676 40 6   12676 40 6   12676 40 6   12676 40 6   12676 40 6
  12676 40 6   12676 40 6   14195 35 5   14195 35 5   14195 35 5   14195 35 5
  14195 35 5   15999 28 4   15999 28 4   15999 28 4   15999 28 4   15999 28 4
  15999 28 4   15999 28 4   17365 22 3   17365 22 3   17365 22 3   17365 22 3
  17365 22 3   17365 22 3   20846 9 2   20846 9 2   20846 9 2   20846 9 2
  20846 9 2   20846 9 2   20846 9 2   20846 9 2   20846 9 2   20846 9 2
  20846 9 2   20846 9 2   20846 9 2   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1}

do_execsql_test 5.1.10.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {777 113 5   777 113 5   777 113 5   777 113 5   777 113 5   805 250 7
  805 250 7   805 250 7   805 250 7   805 250 7   805 250 7   805 250 7
  822 158 6   822 158 6   822 158 6   822 158 6   822 158 6   822 158 6
  840 247 13   840 247 13   840 247 13   840 247 13   840 247 13   840 247 13
  840 247 13   840 247 13   840 247 13   840 247 13   840 247 13   840 247 13
  840 247 13   870 158 0   870 158 0   870 158 0   870 158 0   870 158 0
  870 158 0   899 113 9   899 113 9   899 113 9   899 113 9   899 113 9
  899 113 9   899 113 9   899 113 9   899 113 9   934 223 8   934 223 8
  934 223 8   934 223 8   934 223 8   934 223 8   934 223 8   934 223 8
  938 102 11   938 102 11   938 102 11   938 102 11   938 102 11   938 102 11
  938 102 11   938 102 11   938 102 11   938 102 11   938 102 11   938 148 8
  938 148 8   938 148 8   938 148 8   938 148 8   938 148 8   938 148 8
  938 148 8   959 224 7   959 224 7   959 224 7   959 224 7   959 224 7
  959 224 7   959 224 7   979 133 9   979 133 9   979 133 9   979 133 9
  979 133 9   979 133 9   979 133 9   979 133 9   979 133 9}

do_execsql_test 5.1.10.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {962 1 1   962 1 1   962 1 1   962 1 1   962 1 1   962 1 1   962 1 1
  962 1 1   962 1 1   962 1 1   962 1 1   1264 1 1   1264 1 1   1264 1 1
  1264 1 1   1264 1 1   1264 1 1   1264 1 1   1264 1 1   1366 1 1   1366 1 1
  1366 1 1   1366 1 1   1366 1 1   1366 1 1   1519 1 1   1519 1 1   1519 1 1
  1519 1 1   1519 1 1   1804 1 1   1804 1 1   1804 1 1   1804 1 1   1804 1 1
  1804 1 1   1804 1 1   2050 1 1   2050 1 1   2050 1 1   2050 1 1   2050 1 1
  2050 1 1   2309 1 1   2309 1 1   2309 1 1   2309 1 1   2309 1 1   2309 1 1
  2309 1 1   2309 1 1   2340 1 1   2340 1 1   2340 1 1   2340 1 1   2340 1 1
  2340 1 1   2340 1 1   2947 1 1   2947 1 1   2947 1 1   2947 1 1   2947 1 1
  2947 1 1   2947 1 1   2947 1 1   2947 1 1   3113 1 1   3113 1 1   3113 1 1
  3113 1 1   3113 1 1   3113 1 1   3113 1 1   3113 1 1   3113 1 1   3481 1 1
  3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1
  3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1}

do_execsql_test 5.1.11.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST GROUPS 6 PRECEDING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {934 158 27   934 158 27   934 158 27   934 158 27   934 158 27   934 158 27
  934 223 8   934 223 8   934 223 8   934 223 8   934 223 8   934 223 8
  934 223 8   934 223 8   934 223 21   934 223 21   934 223 21   934 223 21
  934 223 21   934 223 21   934 223 21   934 223 21   934 223 21   934 223 21
  934 223 21   934 223 21   934 223 21   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 102 50   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 102 58   959 102 58   959 102 58   959 102 58
  959 102 58   959 102 58   959 102 58   959 102 58   959 113 39   959 113 39
  959 113 39   959 113 39   959 113 39   959 158 34   959 158 34   959 158 34
  959 158 34   959 158 34   959 158 34   959 158 34   979 102 49   979 102 49
  979 102 49   979 102 49   979 102 49   979 102 49   979 102 53   979 102 53
  979 102 53   979 102 53   979 102 53   979 102 53   979 102 53   979 102 56
  979 102 56   979 102 56   979 102 56   979 102 56   979 102 56   979 102 56
  979 102 56   979 102 56   979 102 59   979 102 59   979 102 59   979 102 59
  979 102 59   979 102 59   979 102 59   979 102 59   979 102 59}

do_execsql_test 5.1.11.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST GROUPS 6 PRECEDING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {2309 1 1   2309 1 1   2309 1 1   2309 1 1   2309 1 1   2309 1 1   2309 1 1
  2309 1 1   5790 9 2   5790 9 2   5790 9 2   5790 9 2   5790 9 2   5790 9 2
  5790 9 2   5790 9 2   5790 9 2   5790 9 2   5790 9 2   5790 9 2   5790 9 2
  7156 22 3   7156 22 3   7156 22 3   7156 22 3   7156 22 3   7156 22 3
  8960 28 4   8960 28 4   8960 28 4   8960 28 4   8960 28 4   8960 28 4
  8960 28 4   10479 35 5   10479 35 5   10479 35 5   10479 35 5   10479 35 5
  11441 40 6   11441 40 6   11441 40 6   11441 40 6   11441 40 6   11441 40 6
  11441 40 6   11441 40 6   11441 40 6   11441 40 6   11441 40 6   12368 68 9
  12368 68 9   12368 68 9   12368 68 9   12368 68 9   12368 68 9   12368 68 9
  12705 51 7   12705 51 7   12705 51 7   12705 51 7   12705 51 7   12705 51 7
  12705 51 7   12705 51 7   13509 59 8   13509 59 8   13509 59 8   13509 59 8
  13509 59 8   13509 59 8   13509 59 8   13509 59 8   13509 59 8
  13949 75 10   13949 75 10   13949 75 10   13949 75 10   13949 75 10
  13949 75 10   13949 75 10   13949 75 10   13949 75 10   14195 84 11
  14195 84 11   14195 84 11   14195 84 11   14195 84 11   14195 84 11}

do_execsql_test 5.1.12.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 2   113 113 2   133 133 1   148 148 1   160 158 2
  160 158 2   160 158 2   208 208 1   224 223 2   224 223 2   239 234 3
  239 234 3   239 234 3   252 247 3   257 247 5   257 247 5   257 250 4
  257 252 3   295 295 1   309 309 1   336 330 3   336 330 3   336 330 3
  346 346 1   355 354 2   355 354 2   355 354 2   399 393 4   399 393 4
  399 393 4   399 393 4   399 393 4   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 2   480 480 2   574 572 2   574 572 2   607 607 1
  618 618 2   618 618 2   634 627 4   634 627 4   634 627 4   634 627 4
  634 629 3   652 652 1   667 660 2   671 667 3   671 667 3   671 667 3
  671 667 3   683 683 1   711 705 2   716 705 3   716 711 2   730 726 2
  730 726 2   762 759 2   768 759 4   768 762 3   768 762 3   777 777 1
  792 786 3   794 786 4   794 786 4   794 790 3   805 805 1   822 822 1
  845 839 5   845 839 5   845 839 5   845 839 5   845 839 5   870 870 2
  870 870 2   870 870 2   899 899 1   911 911 1   934 929 2   938 929 4
  938 934 3   938 934 3   963 959 2   963 959 2   979 979 1}

do_execsql_test 5.1.12.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 25 23   {} 34 29
  {} 36 31   {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 43 37   {} 43 37
  {} 50 42   {} 60 51   {} 61 52   {} 64 55   {} 64 55   {} 67 57   {} 68 58
  {} 69 59   {} 70 60   {} 72 62   {} 78 67   {} 78 67   {} 78 67   {} 85 72
  {} 85 72   133 4 3   223 10 8   223 11 9   226 2 2   226 2 2   239 12 10
  239 13 11   239 14 12   247 15 13   257 18 16   257 19 17   295 20 18
  309 21 19   335 22 20   335 23 21   335 24 22   421 35 30   443 37 32
  504 16 14   504 17 15   607 42 36   683 56 47   710 26 24   710 27 25
  710 27 25   711 59 50   759 62 53   759 63 54   777 66 56   805 71 61
  899 81 68   911 82 69   929 83 70   929 84 71   979 89 75   1334 51 43
  1416 57 48   1416 58 49   1584 29 26   1584 29 26   1584 31 27   1584 32 28
  1584 32 28   1891 49 41   1922 87 73   1922 88 74   2005 52 44   2005 52 44
  2005 54 45   2005 55 46   2518 45 38   2518 46 39   2518 46 39   2518 48 40
  2523 73 63   2523 73 63   2523 75 64   2523 76 65   2523 77 66}

do_execsql_test 5.1.13.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 2   113 113 2   133 133 1   148 148 1   158 158 1
  158 158 1   160 160 1   208 208 1   223 223 1   224 224 1   234 234 1
  238 238 1   239 239 1   247 247 1   250 250 1   252 252 1   256 256 1
  257 257 1   295 295 1   309 309 1   330 330 1   335 335 1   336 336 1
  346 346 1   354 354 1   355 355 1   355 355 1   393 393 2   393 393 2
  398 398 1   399 399 1   399 399 1   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 2   480 480 2   572 572 1   574 574 1   607 607 1
  618 618 2   618 618 2   627 627 1   629 629 1   629 629 1   633 633 1
  634 634 1   652 652 1   660 660 1   667 667 1   667 667 1   670 670 1
  671 671 1   683 683 1   705 705 1   711 711 1   716 716 1   726 726 1
  730 730 1   759 759 1   762 762 1   768 768 2   768 768 2   777 777 1
  786 786 1   790 790 1   792 792 1   794 794 1   805 805 1   822 822 1
  839 839 2   839 839 2   840 840 1   844 844 1   845 845 1   870 870 2
  870 870 2   870 870 2   899 899 1   911 911 1   929 929 1   934 934 1
  938 938 2   938 938 2   959 959 1   963 963 1   979 979 1}

do_execsql_test 5.1.13.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 11 9   {} 12 10
  {} 13 11   {} 16 14   {} 17 15   {} 18 16   {} 22 20   {} 24 22   {} 25 23
  {} 26 24   {} 31 27   {} 34 29   {} 36 31   {} 38 33   {} 38 33   {} 40 34
  {} 41 35   {} 43 37   {} 43 37   {} 49 41   {} 50 42   {} 51 43   {} 54 45
  {} 59 50   {} 60 51   {} 61 52   {} 63 54   {} 64 55   {} 64 55   {} 67 57
  {} 68 58   {} 69 59   {} 70 60   {} 72 62   {} 75 64   {} 76 65   {} 78 67
  {} 78 67   {} 78 67   {} 84 71   {} 85 72   {} 85 72   133 4 3   223 10 8
  226 2 2   226 2 2   239 14 12   247 15 13   257 19 17   295 20 18
  309 21 19   335 23 21   421 35 30   443 37 32   607 42 36   627 45 38
  633 48 40   671 55 46   683 56 47   705 57 48   710 27 25   710 27 25
  711 58 49   759 62 53   777 66 56   786 29 26   786 29 26   798 32 28
  798 32 28   805 71 61   845 77 66   899 81 68   911 82 69   929 83 70
  959 87 73   963 88 74   979 89 75   1258 46 39   1258 46 39   1334 52 44
  1334 52 44   1678 73 63   1678 73 63}

do_execsql_test 5.1.14.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 113 81   979 113 82   979 133 80   979 148 79   979 158 77
  979 158 78   979 160 77   979 208 76   979 223 75   979 224 74   979 234 73
  979 238 72   979 239 71   979 247 70   979 250 69   979 252 68   979 256 67
  979 257 66   979 295 65   979 309 64   979 330 63   979 335 62   979 336 61
  979 346 60   979 354 59   979 355 57   979 355 58   979 393 56   979 393 57
  979 398 55   979 399 53   979 399 54   979 412 53   979 421 52   979 430 51
  979 443 50   979 480 48   979 480 49   979 572 47   979 574 46   979 607 45
  979 618 43   979 618 44   979 627 42   979 629 40   979 629 41   979 633 40
  979 634 39   979 652 38   979 660 37   979 667 35   979 667 36   979 670 35
  979 671 34   979 683 33   979 705 32   979 711 31   979 716 30   979 726 29
  979 730 28   979 759 27   979 762 26   979 768 24   979 768 25   979 777 23
  979 786 22   979 790 21   979 792 20   979 794 19   979 805 18   979 822 17
  979 839 15   979 839 16   979 840 14   979 844 13   979 845 12   979 870 9
  979 870 10   979 870 11   979 899 9   979 911 8   979 929 7}

do_execsql_test 5.1.14.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE NO OTHERS  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {3830 89 89   4741 88 88   5640 84 84   5640 85 85   5640 86 86   5640 87 87
  6485 81 81   6485 82 82   6485 83 83   7324 80 80   8163 78 78   8163 79 79
  8968 73 73   8968 74 74   8968 75 75   8968 76 76   8968 77 77   9745 69 69
  9745 70 70   9745 71 71   9745 72 72   10504 65 65   10504 66 66
  10504 67 67   10504 68 68   11215 64 64   11920 63 63   12603 62 62
  13274 60 60   13274 61 61   13941 59 59   14608 55 55   14608 56 56
  14608 57 57   14608 58 58   15241 54 54   15870 53 53   16499 52 52
  17126 49 49   17126 50 50   17126 51 51   17733 44 44   17733 45 45
  17733 46 46   17733 47 47   17733 48 48   18176 42 42   18176 43 43
  18597 40 40   18597 41 41   18996 39 39   19395 37 37   19395 38 38
  19788 36 36   20181 35 35   20536 34 34   20891 30 30   20891 31 31
  20891 32 32   20891 33 33   21226 28 28   21226 29 29   21535 27 27
  21830 26 26   22087 22 22   22087 23 23   22087 24 24   22087 25 25
  22334 21 21   22573 17 17   22573 18 18   22573 19 19   22573 20 20
  22796 11 11   22796 12 12   22796 13 13   22796 14 14   22796 15 15
  22796 16 16   22929 10 10   23042 9 9   23155 1 1   23155 2 2   23155 3 3
  23155 4 4   23155 5 5   23155 6 6   23155 7 7   23155 8 8}

do_execsql_test 5.2.1.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {963 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 113 82}

do_execsql_test 5.2.1.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {22176 1 1   22192 1 1   22196 1 1   22226 1 1   22244 1 1   22256 1 1
  22310 1 1   22316 1 1   22316 1 1   22350 1 1   22378 1 1   22396 1 1
  22444 1 1   22450 1 1   22472 1 1   22484 1 1   22488 1 1   22488 1 1
  22522 1 1   22526 1 1   22526 1 1   22528 1 1   22548 1 1   22712 1 1
  22734 1 1   22756 1 1   22756 1 1   22762 1 1   22762 1 1   22800 1 1
  22800 1 1   22820 1 1   22846 1 1   22860 1 1   22898 1 1   22908 1 1
  22916 1 1   22932 1 1   23022 1 1   23042 1 1   23042 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1}

do_execsql_test 5.2.2.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {839 113 8   899 113 8   899 113 8   899 113 8   899 113 8   899 113 8
  899 113 8   899 113 8   899 113 15   899 113 15   899 113 15   899 113 15
  899 113 15   899 113 15   899 113 15   899 234 8   963 113 24   979 102 43
  979 102 43   979 102 43   979 102 43   979 102 43   979 102 43   979 102 43
  979 102 43   979 102 43   979 102 43   979 102 48   979 102 48   979 102 48
  979 102 48   979 102 48   979 102 55   979 102 55   979 102 55   979 102 55
  979 102 55   979 102 55   979 102 55   979 102 61   979 102 61   979 102 61
  979 102 61   979 102 61   979 102 61   979 102 74   979 102 74   979 102 74
  979 102 74   979 102 74   979 102 74   979 102 74   979 102 74   979 102 74
  979 102 74   979 102 74   979 102 74   979 102 74   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 113 24   979 113 24   979 113 24   979 113 24   979 113 24   979 113 24
  979 113 24   979 113 24   979 113 32   979 113 32   979 113 32   979 113 32
  979 113 32   979 113 32   979 113 32   979 113 32   979 113 43}

do_execsql_test 5.2.2.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {2048 81 11   2108 81 11   2108 81 11   2690 81 11   2834 81 11   2947 81 11
  2947 81 11   2947 81 11   2947 81 11   4482 74 10   4616 74 10   4844 74 10
  4866 74 10   5287 74 10   5287 74 10   5287 74 10   7421 65 9   7437 65 9
  7717 65 9   8045 65 9   8267 65 9   8400 65 9   8400 65 9   8400 65 9
  8400 65 9   8735 57 8   9329 57 8   9664 57 8   9664 57 8   9664 57 8
  9664 57 8   9664 57 8   9664 57 8   9959 46 7   10331 46 7   10626 46 7
  10626 46 7   10626 46 7   10626 46 7   10626 46 7   10626 46 7   10626 46 7
  10626 46 7   10626 46 7   11368 41 6   11516 41 6   12032 41 6   12145 41 6
  12145 41 6   12990 34 5   13104 34 5   13949 34 5   13949 34 5   13949 34 5
  13949 34 5   13949 34 5   14556 28 4   14708 28 4   15315 28 4   15315 28 4
  15315 28 4   15315 28 4   18085 15 3   18091 15 3   18163 15 3   18397 15 3
  18403 15 3   18403 15 3   18549 15 3   18796 15 3   18796 15 3   18796 15 3
  18796 15 3   18796 15 3   18796 15 3   20194 7 2   20478 7 2   20796 7 2
  20866 7 2   20882 7 2   21105 7 2   21105 7 2   21105 7 2   22488 1 1
  22526 1 1   22756 1 1   22800 1 1   23155 1 1   23155 1 1}

do_execsql_test 5.2.3.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {667 158 0   671 250 6   759 158 5   768 113 4   777 113 4   777 113 4
  777 113 4   777 252 4   792 247 12   805 250 6   805 250 6   805 250 6
  805 250 6   805 250 6   805 398 6   822 158 5   822 158 5   822 158 5
  822 158 5   822 346 5   839 113 8   840 247 12   840 247 12   840 247 12
  840 247 12   840 247 12   840 247 12   840 247 12   840 247 12   840 247 12
  840 247 12   840 247 12   840 393 12   845 224 6   870 102 10   870 158 0
  870 158 0   870 158 0   870 158 0   870 355 0   899 113 8   899 113 8
  899 113 8   899 113 8   899 113 8   899 113 8   899 113 8   899 234 8
  911 223 7   929 148 7   934 223 7   934 223 7   934 223 7   934 223 7
  934 223 7   934 223 7   934 239 7   938 102 10   938 102 10   938 102 10
  938 102 10   938 102 10   938 102 10   938 102 10   938 102 10   938 102 10
  938 148 7   938 148 7   938 148 7   938 148 7   938 148 7   938 148 7
  938 160 7   938 208 10   959 224 6   959 224 6   959 224 6   959 224 6
  959 224 6   959 238 6   963 133 8   979 133 8   979 133 8   979 133 8
  979 133 8   979 133 8   979 133 8   979 133 8   979 330 8}

do_execsql_test 5.2.3.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {295 1 1   335 1 1   607 1 1   667 1 1   742 1 1   759 1 1   845 1 1
  890 1 1   929 1 1   959 1 1   962 1 1   962 1 1   962 1 1   962 1 1
  962 1 1   962 1 1   962 1 1   962 1 1   962 1 1   1264 1 1   1264 1 1
  1264 1 1   1264 1 1   1264 1 1   1264 1 1   1366 1 1   1366 1 1   1366 1 1
  1366 1 1   1383 1 1   1398 1 1   1406 1 1   1421 1 1   1519 1 1   1519 1 1
  1535 1 1   1651 1 1   1669 1 1   1682 1 1   1695 1 1   1804 1 1   1804 1 1
  1804 1 1   1804 1 1   1804 1 1   1897 1 1   1919 1 1   2000 1 1   2048 1 1
  2050 1 1   2050 1 1   2070 1 1   2086 1 1   2108 1 1   2108 1 1   2134 1 1
  2150 1 1   2309 1 1   2309 1 1   2309 1 1   2340 1 1   2340 1 1   2340 1 1
  2430 1 1   2690 1 1   2758 1 1   2770 1 1   2776 1 1   2834 1 1   2848 1 1
  2947 1 1   2947 1 1   2947 1 1   2947 1 1   2980 1 1   3082 1 1   3088 1 1
  3088 1 1   3113 1 1   3113 1 1   3113 1 1   3113 1 1   3234 1 1   3481 1 1
  3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1}

do_execsql_test 5.2.4.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST GROUPS 6 PRECEDING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {667 158 0   870 158 0   870 158 0   870 158 0   870 158 0   870 355 0
  911 158 7   934 158 7   934 158 7   934 158 7   934 158 7   934 158 7
  934 158 7   934 158 7   934 158 20   934 158 20   934 158 20   934 158 20
  934 158 20   934 158 20   934 158 20   934 158 20   934 158 20   934 158 20
  934 158 20   934 158 20   934 158 20   934 158 26   934 158 26   934 158 26
  934 158 26   934 158 26   934 158 26   934 158 33   959 102 49   959 102 49
  959 102 49   959 102 49   959 102 49   959 102 49   959 102 49   959 102 49
  959 102 49   959 102 49   959 102 57   959 102 57   959 102 57   959 102 57
  959 102 57   959 102 57   959 102 57   959 102 57   959 113 38   959 113 38
  959 113 38   959 113 38   959 113 49   959 158 33   959 158 33   959 158 33
  959 158 33   959 158 33   959 158 33   959 158 38   963 102 58   979 102 52
  979 102 52   979 102 52   979 102 52   979 102 52   979 102 52   979 102 52
  979 102 55   979 102 55   979 102 55   979 102 55   979 102 55   979 102 55
  979 102 55   979 102 55   979 102 55   979 102 58   979 102 58   979 102 58
  979 102 58   979 102 58   979 102 58   979 102 58   979 102 58}

do_execsql_test 5.2.4.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST GROUPS 6 PRECEDING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {1383 1 1   1421 1 1   1651 1 1   1695 1 1   2050 1 1   2050 1 1   3448 7 2
  3732 7 2   4050 7 2   4120 7 2   4136 7 2   4359 7 2   4359 7 2   4359 7 2
  7129 15 3   7135 15 3   7207 15 3   7441 15 3   7447 15 3   7447 15 3
  7593 15 3   7840 15 3   7840 15 3   7840 15 3   7840 15 3   7840 15 3
  7840 15 3   8447 28 4   8599 28 4   9206 28 4   9206 28 4   9206 28 4
  9206 28 4   10051 34 5   10165 34 5   11010 34 5   11010 34 5   11010 34 5
  11010 34 5   11010 34 5   11563 74 10   11697 74 10   11752 41 6
  11776 57 8   11900 41 6   11925 74 10   11947 74 10   12368 74 10
  12368 74 10   12368 74 10   12370 57 8   12416 41 6   12529 41 6
  12529 41 6   12530 65 9   12546 65 9   12705 57 8   12705 57 8   12705 57 8
  12705 57 8   12705 57 8   12705 57 8   12824 46 7   12826 65 9
  13050 81 11   13110 81 11   13110 81 11   13154 65 9   13196 46 7
  13376 65 9   13491 46 7   13491 46 7   13491 46 7   13491 46 7   13491 46 7
  13491 46 7   13491 46 7   13491 46 7   13491 46 7   13509 65 9   13509 65 9
  13509 65 9   13509 65 9   13692 81 11   13836 81 11   13949 81 11
  13949 81 11   13949 81 11   13949 81 11}

do_execsql_test 5.2.5.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   113 113 1
  113 113 1   158 158 1   160 158 1   160 158 2   223 223 1   224 224 1
  238 234 2   239 234 2   239 238 2   252 250 2   256 252 2   257 247 4
  257 247 4   257 250 3   335 330 2   336 330 2   336 335 2   355 354 1
  355 354 2   355 355 1   399 393 3   399 393 3   399 393 3   399 393 3
  399 393 4   480 480 1   480 480 1   572 572 1   574 574 1   618 618 1
  618 618 1   633 629 2   634 627 3   634 627 3   634 627 4   634 629 3
  667 667 1   670 667 2   671 667 2   671 667 2   671 667 3   711 711 1
  711 711 1   716 705 2   726 726 1   730 730 1   762 762 1   768 759 3
  768 762 2   768 762 2   792 790 2   792 790 2   794 786 3   794 786 3
  844 839 4   845 839 4   845 839 4   845 839 4   845 839 4   870 870 1
  870 870 1   870 870 2   934 934 1   938 929 3   938 934 2   938 934 2
  959 959 1   963 963 1}

do_execsql_test 5.2.5.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 4 3   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 10 8
  {} 14 12   {} 15 13   {} 19 17   {} 20 18   {} 21 19   {} 23 21   {} 25 23
  {} 34 29   {} 35 30   {} 36 31   {} 37 32   {} 38 33   {} 38 33   {} 40 34
  {} 41 35   {} 42 36   {} 43 37   {} 43 37   {} 50 42   {} 56 47   {} 60 51
  {} 61 52   {} 62 53   {} 64 55   {} 64 55   {} 66 56   {} 67 57   {} 68 58
  {} 69 59   {} 70 60   {} 71 61   {} 72 62   {} 78 67   {} 78 67   {} 78 67
  {} 81 68   {} 82 69   {} 83 70   {} 85 72   {} 85 72   {} 89 75   113 2 2
  113 2 2   223 11 9   239 12 10   239 13 11   257 18 16   335 22 20
  335 24 22   355 27 25   355 27 25   504 16 14   504 17 15   705 58 49
  710 26 24   711 57 48   711 59 50   759 63 54   929 84 71   959 88 74
  963 87 73   1185 32 28   1185 32 28   1191 29 26   1191 29 26   1334 51 43
  1334 55 46   1338 52 44   1338 52 44   1584 31 27   1678 77 66   1684 73 63
  1684 73 63   1885 48 40   1889 46 39   1889 46 39   1891 45 38   1891 49 41
  2005 54 45   2523 75 64   2523 76 65}

do_execsql_test 5.2.6.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   113 113 1
  113 113 1   158 158 0   158 158 1   355 355 0   355 355 1   393 393 1
  393 393 1   399 399 0   399 399 1   480 480 1   480 480 1   618 618 1
  618 618 1   629 629 0   629 629 1   667 667 0   667 667 1   768 768 1
  768 768 1   839 839 1   839 839 1   870 870 1   870 870 1   870 870 2
  938 938 1   938 938 1}

do_execsql_test 5.2.6.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 4 3   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 10 8
  {} 11 9   {} 12 10   {} 13 11   {} 14 12   {} 15 13   {} 16 14   {} 17 15
  {} 18 16   {} 19 17   {} 20 18   {} 21 19   {} 22 20   {} 23 21   {} 24 22
  {} 25 23   {} 26 24   {} 31 27   {} 34 29   {} 35 30   {} 36 31   {} 37 32
  {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 42 36   {} 43 37   {} 43 37
  {} 45 38   {} 48 40   {} 49 41   {} 50 42   {} 51 43   {} 54 45   {} 55 46
  {} 56 47   {} 57 48   {} 58 49   {} 59 50   {} 60 51   {} 61 52   {} 62 53
  {} 63 54   {} 64 55   {} 64 55   {} 66 56   {} 67 57   {} 68 58   {} 69 59
  {} 70 60   {} 71 61   {} 72 62   {} 75 64   {} 76 65   {} 77 66   {} 78 67
  {} 78 67   {} 78 67   {} 81 68   {} 82 69   {} 83 70   {} 84 71   {} 85 72
  {} 85 72   {} 87 73   {} 88 74   {} 89 75   113 2 2   113 2 2   355 27 25
  355 27 25   393 29 26   393 29 26   399 32 28   399 32 28   629 46 39
  629 46 39   667 52 44   667 52 44   839 73 63   839 73 63}

do_execsql_test 5.2.7.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {963 929 6   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 83   979 113 80   979 113 81   979 113 82   979 133 79   979 148 78
  979 158 76   979 158 77   979 160 76   979 208 75   979 223 74   979 224 73
  979 234 72   979 238 71   979 239 70   979 247 69   979 250 68   979 252 67
  979 256 66   979 257 65   979 295 64   979 309 64   979 330 62   979 335 61
  979 336 60   979 346 59   979 354 59   979 355 57   979 355 57   979 393 55
  979 393 56   979 398 54   979 399 53   979 399 53   979 412 52   979 421 51
  979 430 50   979 443 49   979 480 47   979 480 48   979 572 47   979 574 45
  979 607 44   979 618 42   979 618 43   979 627 41   979 629 40   979 629 41
  979 633 39   979 634 38   979 652 37   979 660 36   979 667 35   979 667 35
  979 670 34   979 671 33   979 683 32   979 705 31   979 711 30   979 716 29
  979 726 28   979 730 27   979 759 26   979 762 25   979 768 23   979 768 24
  979 777 22   979 786 21   979 790 20   979 792 19   979 794 18   979 805 17
  979 822 17   979 839 14   979 839 15   979 840 13   979 844 12   979 845 11
  979 870 9   979 870 10   979 870 10   979 899 8   979 911 7}

do_execsql_test 5.2.7.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {2851 89 89   3778 88 88   4681 87 87   5556 83 83   5574 82 82   5586 81 81
  5640 84 84   5640 85 85   5640 86 86   7324 80 80   8123 77 77   8129 73 73
  8129 74 74   8163 78 78   8163 79 79   8940 71 71   8968 75 75   8968 76 76
  9727 66 66   9745 69 69   9745 70 70   9745 72 72   10504 65 65
  10504 67 67   10504 68 68   11215 64 64   11844 62 62   11920 63 63
  13274 60 60   13274 61 61   13897 58 58   13903 57 57   13925 56 56
  13937 55 55   13941 59 59   15203 53 53   15241 54 54   15832 52 52
  17100 48 48   17104 46 46   17104 47 47   17106 45 45   17126 49 49
  17126 50 50   17126 51 51   17569 42 42   17733 44 44   18176 43 43
  18597 40 40   18597 41 41   18952 37 37   18996 39 39   19395 38 38
  19760 35 35   19788 36 36   20492 32 32   20492 33 33   20498 30 30
  20536 34 34   20833 29 29   20871 28 28   20891 31 31   21180 27 27
  21752 23 23   21830 26 26   22025 21 21   22087 22 22   22087 24 24
  22087 25 25   22278 20 20   22316 19 19   22549 15 15   22557 14 14
  22573 17 17   22573 18 18   22706 10 10   22796 11 11   22796 12 12
  22796 13 13   22796 16 16   23022 4 4   23042 2 2   23042 3 3   23042 9 9
  23155 1 1   23155 5 5   23155 6 6   23155 7 7   23155 8 8}

do_execsql_test 5.2.8.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {963 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 113 82}

do_execsql_test 5.2.8.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {22176 1 1   22192 1 1   22196 1 1   22226 1 1   22244 1 1   22256 1 1
  22310 1 1   22316 1 1   22316 1 1   22350 1 1   22378 1 1   22396 1 1
  22444 1 1   22450 1 1   22472 1 1   22484 1 1   22488 1 1   22488 1 1
  22522 1 1   22526 1 1   22526 1 1   22528 1 1   22548 1 1   22712 1 1
  22734 1 1   22756 1 1   22756 1 1   22762 1 1   22762 1 1   22800 1 1
  22800 1 1   22820 1 1   22846 1 1   22860 1 1   22898 1 1   22908 1 1
  22916 1 1   22932 1 1   23022 1 1   23042 1 1   23042 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1
  23155 1 1   23155 1 1   23155 1 1   23155 1 1   23155 1 1}

do_execsql_test 5.2.9.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {667 158 0   870 113 8   870 158 0   870 158 0   870 158 0   870 158 0
  870 355 0   899 113 8   899 113 8   899 113 8   899 113 8   899 113 8
  899 113 8   899 113 8   899 113 15   899 113 15   899 113 15   899 113 15
  899 113 15   899 113 15   899 113 15   899 158 8   963 113 24   979 102 43
  979 102 43   979 102 43   979 102 43   979 102 43   979 102 43   979 102 43
  979 102 43   979 102 43   979 102 43   979 102 48   979 102 48   979 102 48
  979 102 48   979 102 48   979 102 55   979 102 55   979 102 55   979 102 55
  979 102 55   979 102 55   979 102 55   979 102 61   979 102 61   979 102 61
  979 102 61   979 102 61   979 102 61   979 102 74   979 102 74   979 102 74
  979 102 74   979 102 74   979 102 74   979 102 74   979 102 74   979 102 74
  979 102 74   979 102 74   979 102 74   979 102 74   979 102 82   979 102 82
  979 102 82   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 113 24   979 113 24   979 113 24   979 113 24   979 113 24   979 113 24
  979 113 24   979 113 24   979 113 32   979 113 32   979 113 32   979 113 32
  979 113 32   979 113 32   979 113 32   979 113 32   979 113 43}

do_execsql_test 5.2.9.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {1383 84 11   1421 84 11   1651 84 11   1695 84 11   2050 84 11   2050 84 11
  4098 75 10   4158 75 10   4158 75 10   4740 75 10   4884 75 10   4997 75 10
  4997 75 10   4997 75 10   4997 75 10   6532 68 9   6666 68 9   6894 68 9
  6916 68 9   7337 68 9   7337 68 9   7337 68 9   9471 59 8   9487 59 8
  9767 59 8   10095 59 8   10317 59 8   10450 59 8   10450 59 8   10450 59 8
  10450 59 8   10785 51 7   11379 51 7   11714 51 7   11714 51 7   11714 51 7
  11714 51 7   11714 51 7   11714 51 7   12009 40 6   12381 40 6   12676 40 6
  12676 40 6   12676 40 6   12676 40 6   12676 40 6   12676 40 6   12676 40 6
  12676 40 6   12676 40 6   13418 35 5   13566 35 5   14082 35 5   14195 35 5
  14195 35 5   15040 28 4   15154 28 4   15999 28 4   15999 28 4   15999 28 4
  15999 28 4   15999 28 4   16606 22 3   16758 22 3   17365 22 3   17365 22 3
  17365 22 3   17365 22 3   20135 9 2   20141 9 2   20213 9 2   20447 9 2
  20453 9 2   20453 9 2   20599 9 2   20846 9 2   20846 9 2   20846 9 2
  20846 9 2   20846 9 2   20846 9 2   22244 1 1   22528 1 1   22846 1 1
  22916 1 1   22932 1 1   23155 1 1   23155 1 1   23155 1 1}

do_execsql_test 5.2.10.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {667 158 0   671 250 6   759 158 5   768 113 4   777 113 4   777 113 4
  777 113 4   777 252 4   792 247 12   805 250 6   805 250 6   805 250 6
  805 250 6   805 250 6   805 398 6   822 158 5   822 158 5   822 158 5
  822 158 5   822 346 5   839 113 8   840 247 12   840 247 12   840 247 12
  840 247 12   840 247 12   840 247 12   840 247 12   840 247 12   840 247 12
  840 247 12   840 247 12   840 393 12   845 224 6   870 102 10   870 158 0
  870 158 0   870 158 0   870 158 0   870 355 0   899 113 8   899 113 8
  899 113 8   899 113 8   899 113 8   899 113 8   899 113 8   899 234 8
  911 223 7   929 148 7   934 223 7   934 223 7   934 223 7   934 223 7
  934 223 7   934 223 7   934 239 7   938 102 10   938 102 10   938 102 10
  938 102 10   938 102 10   938 102 10   938 102 10   938 102 10   938 102 10
  938 148 7   938 148 7   938 148 7   938 148 7   938 148 7   938 148 7
  938 160 7   938 208 10   959 224 6   959 224 6   959 224 6   959 224 6
  959 224 6   959 238 6   963 133 8   979 133 8   979 133 8   979 133 8
  979 133 8   979 133 8   979 133 8   979 133 8   979 330 8}

do_execsql_test 5.2.10.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {295 1 1   335 1 1   607 1 1   667 1 1   742 1 1   759 1 1   845 1 1
  890 1 1   929 1 1   959 1 1   962 1 1   962 1 1   962 1 1   962 1 1
  962 1 1   962 1 1   962 1 1   962 1 1   962 1 1   1264 1 1   1264 1 1
  1264 1 1   1264 1 1   1264 1 1   1264 1 1   1366 1 1   1366 1 1   1366 1 1
  1366 1 1   1383 1 1   1398 1 1   1406 1 1   1421 1 1   1519 1 1   1519 1 1
  1535 1 1   1651 1 1   1669 1 1   1682 1 1   1695 1 1   1804 1 1   1804 1 1
  1804 1 1   1804 1 1   1804 1 1   1897 1 1   1919 1 1   2000 1 1   2048 1 1
  2050 1 1   2050 1 1   2070 1 1   2086 1 1   2108 1 1   2108 1 1   2134 1 1
  2150 1 1   2309 1 1   2309 1 1   2309 1 1   2340 1 1   2340 1 1   2340 1 1
  2430 1 1   2690 1 1   2758 1 1   2770 1 1   2776 1 1   2834 1 1   2848 1 1
  2947 1 1   2947 1 1   2947 1 1   2947 1 1   2980 1 1   3082 1 1   3088 1 1
  3088 1 1   3113 1 1   3113 1 1   3113 1 1   3113 1 1   3234 1 1   3481 1 1
  3481 1 1   3481 1 1   3481 1 1   3481 1 1   3481 1 1}

do_execsql_test 5.2.11.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST GROUPS 6 PRECEDING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {911 223 7   934 158 26   934 158 26   934 158 26   934 158 26   934 158 26
  934 158 33   934 223 7   934 223 7   934 223 7   934 223 7   934 223 7
  934 223 7   934 223 20   934 223 20   934 223 20   934 223 20   934 223 20
  934 223 20   934 223 20   934 223 20   934 223 20   934 223 20   934 223 20
  934 223 20   934 223 20   934 223 26   934 239 7   959 102 49   959 102 49
  959 102 49   959 102 49   959 102 49   959 102 49   959 102 49   959 102 49
  959 102 49   959 102 49   959 102 57   959 102 57   959 102 57   959 102 57
  959 102 57   959 102 57   959 102 57   959 102 57   959 113 38   959 113 38
  959 113 38   959 113 38   959 113 49   959 158 33   959 158 33   959 158 33
  959 158 33   959 158 33   959 158 33   959 158 38   963 102 58   979 102 49
  979 102 49   979 102 49   979 102 49   979 102 49   979 102 49   979 102 52
  979 102 52   979 102 52   979 102 52   979 102 52   979 102 52   979 102 52
  979 102 55   979 102 55   979 102 55   979 102 55   979 102 55   979 102 55
  979 102 55   979 102 55   979 102 55   979 102 58   979 102 58   979 102 58
  979 102 58   979 102 58   979 102 58   979 102 58   979 102 58}

do_execsql_test 5.2.11.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST GROUPS 6 PRECEDING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {1398 1 1   1682 1 1   2000 1 1   2070 1 1   2086 1 1   2309 1 1   2309 1 1
  2309 1 1   5079 9 2   5085 9 2   5157 9 2   5391 9 2   5397 9 2   5397 9 2
  5543 9 2   5790 9 2   5790 9 2   5790 9 2   5790 9 2   5790 9 2   5790 9 2
  6397 22 3   6549 22 3   7156 22 3   7156 22 3   7156 22 3   7156 22 3
  8001 28 4   8115 28 4   8960 28 4   8960 28 4   8960 28 4   8960 28 4
  8960 28 4   9702 35 5   9850 35 5   10366 35 5   10479 35 5   10479 35 5
  10774 40 6   11146 40 6   11441 40 6   11441 40 6   11441 40 6   11441 40 6
  11441 40 6   11441 40 6   11441 40 6   11441 40 6   11441 40 6   11563 68 9
  11697 68 9   11776 51 7   11925 68 9   11947 68 9   12368 68 9   12368 68 9
  12368 68 9   12370 51 7   12530 59 8   12546 59 8   12705 51 7   12705 51 7
  12705 51 7   12705 51 7   12705 51 7   12705 51 7   12826 59 8
  13050 75 10   13110 75 10   13110 75 10   13154 59 8   13376 59 8
  13509 59 8   13509 59 8   13509 59 8   13509 59 8   13528 84 11
  13566 84 11   13692 75 10   13796 84 11   13836 75 10   13840 84 11
  13949 75 10   13949 75 10   13949 75 10   13949 75 10   14195 84 11
  14195 84 11}

do_execsql_test 5.2.12.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   113 113 1
  113 113 1   158 158 1   160 158 1   160 158 2   223 223 1   224 224 1
  238 234 2   239 234 2   239 238 2   252 250 2   256 252 2   257 247 4
  257 247 4   257 250 3   335 330 2   336 330 2   336 335 2   355 354 1
  355 354 2   355 355 1   399 393 3   399 393 3   399 393 3   399 393 3
  399 393 4   480 480 1   480 480 1   572 572 1   574 574 1   618 618 1
  618 618 1   633 629 2   634 627 3   634 627 3   634 627 4   634 629 3
  667 667 1   670 667 2   671 667 2   671 667 2   671 667 3   711 711 1
  711 711 1   716 705 2   726 726 1   730 730 1   762 762 1   768 759 3
  768 762 2   768 762 2   792 790 2   792 790 2   794 786 3   794 786 3
  844 839 4   845 839 4   845 839 4   845 839 4   845 839 4   870 870 1
  870 870 1   870 870 2   934 934 1   938 929 3   938 934 2   938 934 2
  959 959 1   963 963 1}

do_execsql_test 5.2.12.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 4 3   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 10 8
  {} 14 12   {} 15 13   {} 19 17   {} 20 18   {} 21 19   {} 23 21   {} 25 23
  {} 34 29   {} 35 30   {} 36 31   {} 37 32   {} 38 33   {} 38 33   {} 40 34
  {} 41 35   {} 42 36   {} 43 37   {} 43 37   {} 50 42   {} 56 47   {} 60 51
  {} 61 52   {} 62 53   {} 64 55   {} 64 55   {} 66 56   {} 67 57   {} 68 58
  {} 69 59   {} 70 60   {} 71 61   {} 72 62   {} 78 67   {} 78 67   {} 78 67
  {} 81 68   {} 82 69   {} 83 70   {} 85 72   {} 85 72   {} 89 75   113 2 2
  113 2 2   223 11 9   239 12 10   239 13 11   257 18 16   335 22 20
  335 24 22   355 27 25   355 27 25   504 16 14   504 17 15   705 58 49
  710 26 24   711 57 48   711 59 50   759 63 54   929 84 71   959 88 74
  963 87 73   1185 32 28   1185 32 28   1191 29 26   1191 29 26   1334 51 43
  1334 55 46   1338 52 44   1338 52 44   1584 31 27   1678 77 66   1684 73 63
  1684 73 63   1885 48 40   1889 46 39   1889 46 39   1891 45 38   1891 49 41
  2005 54 45   2523 75 64   2523 76 65}

do_execsql_test 5.2.13.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   113 113 1
  113 113 1   158 158 0   158 158 1   355 355 0   355 355 1   393 393 1
  393 393 1   399 399 0   399 399 1   480 480 1   480 480 1   618 618 1
  618 618 1   629 629 0   629 629 1   667 667 0   667 667 1   768 768 1
  768 768 1   839 839 1   839 839 1   870 870 1   870 870 1   870 870 2
  938 938 1   938 938 1}

do_execsql_test 5.2.13.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 4 3   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 10 8
  {} 11 9   {} 12 10   {} 13 11   {} 14 12   {} 15 13   {} 16 14   {} 17 15
  {} 18 16   {} 19 17   {} 20 18   {} 21 19   {} 22 20   {} 23 21   {} 24 22
  {} 25 23   {} 26 24   {} 31 27   {} 34 29   {} 35 30   {} 36 31   {} 37 32
  {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 42 36   {} 43 37   {} 43 37
  {} 45 38   {} 48 40   {} 49 41   {} 50 42   {} 51 43   {} 54 45   {} 55 46
  {} 56 47   {} 57 48   {} 58 49   {} 59 50   {} 60 51   {} 61 52   {} 62 53
  {} 63 54   {} 64 55   {} 64 55   {} 66 56   {} 67 57   {} 68 58   {} 69 59
  {} 70 60   {} 71 61   {} 72 62   {} 75 64   {} 76 65   {} 77 66   {} 78 67
  {} 78 67   {} 78 67   {} 81 68   {} 82 69   {} 83 70   {} 84 71   {} 85 72
  {} 85 72   {} 87 73   {} 88 74   {} 89 75   113 2 2   113 2 2   355 27 25
  355 27 25   393 29 26   393 29 26   399 32 28   399 32 28   629 46 39
  629 46 39   667 52 44   667 52 44   839 73 63   839 73 63}

do_execsql_test 5.2.14.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {963 929 6   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 83   979 113 80   979 113 81   979 113 82   979 133 79   979 148 78
  979 158 76   979 158 77   979 160 76   979 208 75   979 223 74   979 224 73
  979 234 72   979 238 71   979 239 70   979 247 69   979 250 68   979 252 67
  979 256 66   979 257 65   979 295 64   979 309 63   979 330 63   979 335 61
  979 336 60   979 346 59   979 354 58   979 355 56   979 355 58   979 393 55
  979 393 56   979 398 54   979 399 52   979 399 53   979 412 52   979 421 51
  979 430 50   979 443 49   979 480 47   979 480 48   979 572 46   979 574 46
  979 607 44   979 618 42   979 618 43   979 627 41   979 629 40   979 629 40
  979 633 39   979 634 38   979 652 37   979 660 36   979 667 34   979 667 35
  979 670 34   979 671 33   979 683 32   979 705 31   979 711 30   979 716 29
  979 726 28   979 730 27   979 759 26   979 762 25   979 768 23   979 768 24
  979 777 22   979 786 21   979 790 20   979 792 19   979 794 18   979 805 17
  979 822 16   979 839 15   979 839 15   979 840 13   979 844 12   979 845 11
  979 870 8   979 870 9   979 870 10   979 899 8   979 911 7}

do_execsql_test 5.2.14.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE CURRENT ROW  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {2851 89 89   3778 88 88   4681 87 87   5556 83 83   5574 82 82   5586 81 81
  5640 84 84   5640 85 85   5640 86 86   7324 80 80   8123 77 77   8129 73 73
  8129 74 74   8163 78 78   8163 79 79   8940 71 71   8968 75 75   8968 76 76
  9727 66 66   9745 69 69   9745 70 70   9745 72 72   10504 65 65
  10504 67 67   10504 68 68   11215 64 64   11844 62 62   11920 63 63
  13274 60 60   13274 61 61   13897 58 58   13903 57 57   13925 56 56
  13937 55 55   13941 59 59   15203 53 53   15241 54 54   15832 52 52
  17100 48 48   17104 46 46   17104 47 47   17106 45 45   17126 49 49
  17126 50 50   17126 51 51   17569 42 42   17733 44 44   18176 43 43
  18597 40 40   18597 41 41   18952 37 37   18996 39 39   19395 38 38
  19760 35 35   19788 36 36   20492 32 32   20492 33 33   20498 30 30
  20536 34 34   20833 29 29   20871 28 28   20891 31 31   21180 27 27
  21752 23 23   21830 26 26   22025 21 21   22087 22 22   22087 24 24
  22087 25 25   22278 20 20   22316 19 19   22549 15 15   22557 14 14
  22573 17 17   22573 18 18   22706 10 10   22796 11 11   22796 12 12
  22796 13 13   22796 16 16   23022 4 4   23042 2 2   23042 3 3   23042 9 9
  23155 1 1   23155 5 5   23155 6 6   23155 7 7   23155 8 8}

do_execsql_test 5.3.1.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0}

do_execsql_test 5.3.1.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1}

do_execsql_test 5.3.2.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   899 113 9   899 113 9   899 113 9   899 113 9
  899 113 9   899 113 9   899 113 9   899 113 16   899 113 16   899 113 16
  899 113 16   899 113 16   899 113 16   899 113 16   899 113 16   899 113 16
  979 102 44   979 102 44   979 102 44   979 102 44   979 102 44   979 102 49
  979 102 49   979 102 49   979 102 49   979 102 49   979 102 49   979 102 49
  979 102 56   979 102 56   979 102 56   979 102 56   979 102 56   979 102 56
  979 102 62   979 102 62   979 102 62   979 102 62   979 102 62   979 102 62
  979 102 62   979 102 62   979 102 62   979 102 62   979 102 62   979 102 62
  979 102 62   979 102 75   979 102 75   979 102 75   979 102 75   979 102 75
  979 102 75   979 102 75   979 102 75   979 102 83   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 113 25   979 113 25   979 113 25
  979 113 25   979 113 25   979 113 25   979 113 25   979 113 25   979 113 33
  979 113 33   979 113 33   979 113 33   979 113 33   979 113 33   979 113 33
  979 113 33   979 113 33   979 113 33   979 113 33}

do_execsql_test 5.3.2.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 81 11   {} 81 11   {} 81 11   {} 81 11   {} 81 11   {} 81 11   {} 81 11
  {} 81 11   {} 81 11   2947 74 10   2947 74 10   2947 74 10   2947 74 10
  2947 74 10   2947 74 10   2947 74 10   5287 65 9   5287 65 9   5287 65 9
  5287 65 9   5287 65 9   5287 65 9   5287 65 9   5287 65 9   5287 65 9
  8400 57 8   8400 57 8   8400 57 8   8400 57 8   8400 57 8   8400 57 8
  8400 57 8   8400 57 8   9664 46 7   9664 46 7   9664 46 7   9664 46 7
  9664 46 7   9664 46 7   9664 46 7   9664 46 7   9664 46 7   9664 46 7
  9664 46 7   10626 41 6   10626 41 6   10626 41 6   10626 41 6   10626 41 6
  12145 34 5   12145 34 5   12145 34 5   12145 34 5   12145 34 5   12145 34 5
  12145 34 5   13949 28 4   13949 28 4   13949 28 4   13949 28 4   13949 28 4
  13949 28 4   15315 15 3   15315 15 3   15315 15 3   15315 15 3   15315 15 3
  15315 15 3   15315 15 3   15315 15 3   15315 15 3   15315 15 3   15315 15 3
  15315 15 3   15315 15 3   18796 7 2   18796 7 2   18796 7 2   18796 7 2
  18796 7 2   18796 7 2   18796 7 2   18796 7 2   21105 1 1   21105 1 1
  21105 1 1   21105 1 1   21105 1 1   21105 1 1}

do_execsql_test 5.3.3.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0}

do_execsql_test 5.3.3.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1}

do_execsql_test 5.3.4.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST GROUPS 6 PRECEDING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   870 158 0
  870 158 0   870 158 0   870 158 0   870 158 0   870 158 0   870 158 0
  870 158 0   934 158 8   934 158 8   934 158 8   934 158 8   934 158 8
  934 158 8   934 158 8   934 158 8   934 158 8   934 158 8   934 158 8
  934 158 8   934 158 8   934 158 21   934 158 21   934 158 21   934 158 21
  934 158 21   934 158 21   934 158 27   934 158 27   934 158 27   934 158 27
  934 158 27   934 158 27   934 158 27   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 102 50   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 102 50   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 113 39   959 113 39   959 113 39   959 113 39
  959 113 39   959 113 39   959 113 39   959 113 39   959 113 39   959 113 39
  959 113 39   959 158 34   959 158 34   959 158 34   959 158 34   959 158 34
  979 102 46   979 102 46   979 102 46   979 102 46   979 102 46   979 102 46
  979 102 46   979 102 47   979 102 47   979 102 47   979 102 47   979 102 47
  979 102 47   979 102 47   979 102 47   979 102 47}

do_execsql_test 5.3.4.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST GROUPS 6 PRECEDING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   2050 7 2   2050 7 2
  2050 7 2   2050 7 2   2050 7 2   2050 7 2   2050 7 2   2050 7 2   4359 15 3
  4359 15 3   4359 15 3   4359 15 3   4359 15 3   4359 15 3   4359 15 3
  4359 15 3   4359 15 3   4359 15 3   4359 15 3   4359 15 3   4359 15 3
  7840 28 4   7840 28 4   7840 28 4   7840 28 4   7840 28 4   7840 28 4
  9206 34 5   9206 34 5   9206 34 5   9206 34 5   9206 34 5   9206 34 5
  9206 34 5   10028 74 10   10028 74 10   10028 74 10   10028 74 10
  10028 74 10   10028 74 10   10028 74 10   10396 65 9   10396 65 9
  10396 65 9   10396 65 9   10396 65 9   10396 65 9   10396 65 9   10396 65 9
  10396 65 9   11002 81 11   11002 81 11   11002 81 11   11002 81 11
  11002 81 11   11002 81 11   11002 81 11   11002 81 11   11002 81 11
  11010 41 6   11010 41 6   11010 41 6   11010 41 6   11010 41 6   11441 57 8
  11441 57 8   11441 57 8   11441 57 8   11441 57 8   11441 57 8   11441 57 8
  11441 57 8   12529 46 7   12529 46 7   12529 46 7   12529 46 7   12529 46 7
  12529 46 7   12529 46 7   12529 46 7   12529 46 7   12529 46 7   12529 46 7}

do_execsql_test 5.3.5.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   158 158 1   160 160 1   160 160 1   223 223 1   224 224 1
  238 234 2   239 234 2   239 238 2   252 250 2   256 252 2   257 247 4
  257 247 4   257 250 3   335 330 2   336 330 2   336 335 2   354 354 1
  354 354 1   355 355 1   398 393 3   398 393 3   399 393 3   399 398 2
  399 398 2   572 572 1   574 574 1   633 629 2   634 627 3   634 627 3
  634 627 3   634 629 3   667 667 1   670 667 2   671 667 2   671 670 2
  671 670 2   711 711 1   711 711 1   716 705 2   726 726 1   730 730 1
  762 762 1   762 762 1   762 762 1   768 759 3   792 790 2   792 790 2
  794 786 3   794 786 3   844 839 4   845 839 4   845 839 4   845 840 3
  845 840 3   934 934 1   934 934 1   934 934 1   938 929 3   959 959 1
  963 963 1}

do_execsql_test 5.3.5.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 2 2   {} 2 2   {} 4 3   {} 5 4   {} 6 5   {} 6 5   {} 8 6
  {} 9 7   {} 10 8   {} 14 12   {} 15 13   {} 19 17   {} 20 18   {} 21 19
  {} 23 21   {} 25 23   {} 27 25   {} 27 25   {} 34 29   {} 35 30   {} 36 31
  {} 37 32   {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 42 36   {} 43 37
  {} 43 37   {} 50 42   {} 56 47   {} 60 51   {} 61 52   {} 62 53   {} 64 55
  {} 64 55   {} 66 56   {} 67 57   {} 68 58   {} 69 59   {} 70 60   {} 71 61
  {} 72 62   {} 78 67   {} 78 67   {} 78 67   {} 81 68   {} 82 69   {} 83 70
  {} 85 72   {} 85 72   {} 89 75   223 11 9   239 12 10   239 13 11
  257 18 16   335 22 20   335 24 22   504 16 14   504 17 15   671 52 44
  671 52 44   705 58 49   710 26 24   711 57 48   711 59 50   759 63 54
  786 32 28   786 32 28   798 29 26   798 29 26   845 73 63   845 73 63
  929 84 71   959 88 74   963 87 73   1260 46 39   1260 46 39   1334 51 43
  1334 55 46   1584 31 27   1678 77 66   1885 48 40   1891 45 38   1891 49 41
  2005 54 45   2523 75 64   2523 76 65}

do_execsql_test 5.3.6.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0}

do_execsql_test 5.3.6.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 2 2   {} 2 2   {} 4 3   {} 5 4   {} 6 5   {} 6 5   {} 8 6
  {} 9 7   {} 10 8   {} 11 9   {} 12 10   {} 13 11   {} 14 12   {} 15 13
  {} 16 14   {} 17 15   {} 18 16   {} 19 17   {} 20 18   {} 21 19   {} 22 20
  {} 23 21   {} 24 22   {} 25 23   {} 26 24   {} 27 25   {} 27 25   {} 29 26
  {} 29 26   {} 31 27   {} 32 28   {} 32 28   {} 34 29   {} 35 30   {} 36 31
  {} 37 32   {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 42 36   {} 43 37
  {} 43 37   {} 45 38   {} 46 39   {} 46 39   {} 48 40   {} 49 41   {} 50 42
  {} 51 43   {} 52 44   {} 52 44   {} 54 45   {} 55 46   {} 56 47   {} 57 48
  {} 58 49   {} 59 50   {} 60 51   {} 61 52   {} 62 53   {} 63 54   {} 64 55
  {} 64 55   {} 66 56   {} 67 57   {} 68 58   {} 69 59   {} 70 60   {} 71 61
  {} 72 62   {} 73 63   {} 73 63   {} 75 64   {} 76 65   {} 77 66   {} 78 67
  {} 78 67   {} 78 67   {} 81 68   {} 82 69   {} 83 70   {} 84 71   {} 85 72
  {} 85 72   {} 87 73   {} 88 74   {} 89 75}

do_execsql_test 5.3.7.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {963 929 6   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 83   979 113 80   979 113 81   979 113 82   979 133 79   979 148 78
  979 158 76   979 158 77   979 160 76   979 208 75   979 223 74   979 224 73
  979 234 72   979 238 71   979 239 70   979 247 69   979 250 68   979 252 67
  979 256 66   979 257 65   979 295 64   979 309 64   979 330 62   979 335 61
  979 336 60   979 346 59   979 354 59   979 355 57   979 355 57   979 393 55
  979 393 56   979 398 54   979 399 53   979 399 53   979 412 52   979 421 51
  979 430 50   979 443 49   979 480 47   979 480 48   979 572 47   979 574 45
  979 607 44   979 618 42   979 618 43   979 627 41   979 629 40   979 629 41
  979 633 39   979 634 38   979 652 37   979 660 36   979 667 35   979 667 35
  979 670 34   979 671 33   979 683 32   979 705 31   979 711 30   979 716 29
  979 726 28   979 730 27   979 759 26   979 762 25   979 768 23   979 768 24
  979 777 22   979 786 21   979 790 20   979 792 19   979 794 18   979 805 17
  979 822 17   979 839 14   979 839 15   979 840 13   979 844 12   979 845 11
  979 870 9   979 870 10   979 870 10   979 899 8   979 911 7}

do_execsql_test 5.3.7.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {2851 89 89   3778 88 88   4681 87 87   5556 83 83   5574 82 82   5586 81 81
  5640 84 84   5640 85 85   5640 86 86   7324 80 80   8123 77 77   8129 73 73
  8129 74 74   8163 78 78   8163 79 79   8940 71 71   8968 75 75   8968 76 76
  9727 66 66   9745 69 69   9745 70 70   9745 72 72   10504 65 65
  10504 67 67   10504 68 68   11215 64 64   11844 62 62   11920 63 63
  13274 60 60   13274 61 61   13897 58 58   13903 57 57   13925 56 56
  13937 55 55   13941 59 59   15203 53 53   15241 54 54   15832 52 52
  17100 48 48   17104 46 46   17104 47 47   17106 45 45   17126 49 49
  17126 50 50   17126 51 51   17569 42 42   17733 44 44   18176 43 43
  18597 40 40   18597 41 41   18952 37 37   18996 39 39   19395 38 38
  19760 35 35   19788 36 36   20492 32 32   20492 33 33   20498 30 30
  20536 34 34   20833 29 29   20871 28 28   20891 31 31   21180 27 27
  21752 23 23   21830 26 26   22025 21 21   22087 22 22   22087 24 24
  22087 25 25   22278 20 20   22316 19 19   22549 15 15   22557 14 14
  22573 17 17   22573 18 18   22706 10 10   22796 11 11   22796 12 12
  22796 13 13   22796 16 16   23022 4 4   23042 2 2   23042 3 3   23042 9 9
  23155 1 1   23155 5 5   23155 6 6   23155 7 7   23155 8 8}

do_execsql_test 5.3.8.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0}

do_execsql_test 5.3.8.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1}

do_execsql_test 5.3.9.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   870 158 0
  870 158 0   870 158 0   870 158 0   870 158 0   870 158 0   870 158 0
  870 158 0   870 158 0   899 113 9   899 113 9   899 113 9   899 113 9
  899 113 9   899 113 9   899 113 9   899 113 16   899 113 16   899 113 16
  899 113 16   899 113 16   899 113 16   899 113 16   899 113 16   899 113 16
  979 102 44   979 102 44   979 102 44   979 102 44   979 102 44   979 102 49
  979 102 49   979 102 49   979 102 49   979 102 49   979 102 49   979 102 49
  979 102 56   979 102 56   979 102 56   979 102 56   979 102 56   979 102 56
  979 102 62   979 102 62   979 102 62   979 102 62   979 102 62   979 102 62
  979 102 62   979 102 62   979 102 62   979 102 62   979 102 62   979 102 62
  979 102 62   979 102 75   979 102 75   979 102 75   979 102 75   979 102 75
  979 102 75   979 102 75   979 102 75   979 113 25   979 113 25   979 113 25
  979 113 25   979 113 25   979 113 25   979 113 25   979 113 25   979 113 33
  979 113 33   979 113 33   979 113 33   979 113 33   979 113 33   979 113 33
  979 113 33   979 113 33   979 113 33   979 113 33}

do_execsql_test 5.3.9.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 84 11   {} 84 11   {} 84 11   {} 84 11   {} 84 11   {} 84 11
  2050 75 10   2050 75 10   2050 75 10   2050 75 10   2050 75 10   2050 75 10
  2050 75 10   2050 75 10   2050 75 10   4997 68 9   4997 68 9   4997 68 9
  4997 68 9   4997 68 9   4997 68 9   4997 68 9   7337 59 8   7337 59 8
  7337 59 8   7337 59 8   7337 59 8   7337 59 8   7337 59 8   7337 59 8
  7337 59 8   10450 51 7   10450 51 7   10450 51 7   10450 51 7   10450 51 7
  10450 51 7   10450 51 7   10450 51 7   11714 40 6   11714 40 6   11714 40 6
  11714 40 6   11714 40 6   11714 40 6   11714 40 6   11714 40 6   11714 40 6
  11714 40 6   11714 40 6   12676 35 5   12676 35 5   12676 35 5   12676 35 5
  12676 35 5   14195 28 4   14195 28 4   14195 28 4   14195 28 4   14195 28 4
  14195 28 4   14195 28 4   15999 22 3   15999 22 3   15999 22 3   15999 22 3
  15999 22 3   15999 22 3   17365 9 2   17365 9 2   17365 9 2   17365 9 2
  17365 9 2   17365 9 2   17365 9 2   17365 9 2   17365 9 2   17365 9 2
  17365 9 2   17365 9 2   17365 9 2   20846 1 1   20846 1 1   20846 1 1
  20846 1 1   20846 1 1   20846 1 1   20846 1 1   20846 1 1}

do_execsql_test 5.3.10.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0}

do_execsql_test 5.3.10.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1}

do_execsql_test 5.3.11.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST GROUPS 6 PRECEDING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   934 158 27   934 158 27   934 158 27   934 158 27   934 158 27
  934 158 27   934 158 27   934 223 8   934 223 8   934 223 8   934 223 8
  934 223 8   934 223 8   934 223 8   934 223 8   934 223 8   934 223 8
  934 223 8   934 223 8   934 223 8   934 223 21   934 223 21   934 223 21
  934 223 21   934 223 21   934 223 21   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 102 50   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 102 50   959 102 50   959 102 50   959 102 50
  959 102 50   959 102 50   959 113 39   959 113 39   959 113 39   959 113 39
  959 113 39   959 113 39   959 113 39   959 113 39   959 113 39   959 113 39
  959 113 39   959 158 34   959 158 34   959 158 34   959 158 34   959 158 34
  979 102 46   979 102 46   979 102 46   979 102 46   979 102 46   979 102 46
  979 102 46   979 102 47   979 102 47   979 102 47   979 102 47   979 102 47
  979 102 47   979 102 47   979 102 47   979 102 47   979 102 49   979 102 49
  979 102 49   979 102 49   979 102 49   979 102 49}

do_execsql_test 5.3.11.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST GROUPS 6 PRECEDING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  2309 9 2   2309 9 2   2309 9 2   2309 9 2   2309 9 2   2309 9 2   2309 9 2
  2309 9 2   2309 9 2   2309 9 2   2309 9 2   2309 9 2   2309 9 2   5790 22 3
  5790 22 3   5790 22 3   5790 22 3   5790 22 3   5790 22 3   7156 28 4
  7156 28 4   7156 28 4   7156 28 4   7156 28 4   7156 28 4   7156 28 4
  8960 35 5   8960 35 5   8960 35 5   8960 35 5   8960 35 5   10028 68 9
  10028 68 9   10028 68 9   10028 68 9   10028 68 9   10028 68 9   10028 68 9
  10396 59 8   10396 59 8   10396 59 8   10396 59 8   10396 59 8   10396 59 8
  10396 59 8   10396 59 8   10396 59 8   10479 40 6   10479 40 6   10479 40 6
  10479 40 6   10479 40 6   10479 40 6   10479 40 6   10479 40 6   10479 40 6
  10479 40 6   10479 40 6   11002 75 10   11002 75 10   11002 75 10
  11002 75 10   11002 75 10   11002 75 10   11002 75 10   11002 75 10
  11002 75 10   11441 51 7   11441 51 7   11441 51 7   11441 51 7
  11441 51 7   11441 51 7   11441 51 7   11441 51 7   12145 84 11
  12145 84 11   12145 84 11   12145 84 11   12145 84 11   12145 84 11}

do_execsql_test 5.3.12.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   158 158 1   160 160 1   160 160 1   223 223 1   224 224 1
  238 234 2   239 234 2   239 238 2   252 250 2   256 252 2   257 247 4
  257 247 4   257 250 3   335 330 2   336 330 2   336 335 2   354 354 1
  354 354 1   355 355 1   398 393 3   398 393 3   399 393 3   399 398 2
  399 398 2   572 572 1   574 574 1   633 629 2   634 627 3   634 627 3
  634 627 3   634 629 3   667 667 1   670 667 2   671 667 2   671 670 2
  671 670 2   711 711 1   711 711 1   716 705 2   726 726 1   730 730 1
  762 762 1   762 762 1   762 762 1   768 759 3   792 790 2   792 790 2
  794 786 3   794 786 3   844 839 4   845 839 4   845 839 4   845 840 3
  845 840 3   934 934 1   934 934 1   934 934 1   938 929 3   959 959 1
  963 963 1}

do_execsql_test 5.3.12.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 2 2   {} 2 2   {} 4 3   {} 5 4   {} 6 5   {} 6 5   {} 8 6
  {} 9 7   {} 10 8   {} 14 12   {} 15 13   {} 19 17   {} 20 18   {} 21 19
  {} 23 21   {} 25 23   {} 27 25   {} 27 25   {} 34 29   {} 35 30   {} 36 31
  {} 37 32   {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 42 36   {} 43 37
  {} 43 37   {} 50 42   {} 56 47   {} 60 51   {} 61 52   {} 62 53   {} 64 55
  {} 64 55   {} 66 56   {} 67 57   {} 68 58   {} 69 59   {} 70 60   {} 71 61
  {} 72 62   {} 78 67   {} 78 67   {} 78 67   {} 81 68   {} 82 69   {} 83 70
  {} 85 72   {} 85 72   {} 89 75   223 11 9   239 12 10   239 13 11
  257 18 16   335 22 20   335 24 22   504 16 14   504 17 15   671 52 44
  671 52 44   705 58 49   710 26 24   711 57 48   711 59 50   759 63 54
  786 32 28   786 32 28   798 29 26   798 29 26   845 73 63   845 73 63
  929 84 71   959 88 74   963 87 73   1260 46 39   1260 46 39   1334 51 43
  1334 55 46   1584 31 27   1678 77 66   1885 48 40   1891 45 38   1891 49 41
  2005 54 45   2523 75 64   2523 76 65}

do_execsql_test 5.3.13.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0
  {} {} 0   {} {} 0   {} {} 0   {} {} 0   {} {} 0}

do_execsql_test 5.3.13.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 2 2   {} 2 2   {} 4 3   {} 5 4   {} 6 5   {} 6 5   {} 8 6
  {} 9 7   {} 10 8   {} 11 9   {} 12 10   {} 13 11   {} 14 12   {} 15 13
  {} 16 14   {} 17 15   {} 18 16   {} 19 17   {} 20 18   {} 21 19   {} 22 20
  {} 23 21   {} 24 22   {} 25 23   {} 26 24   {} 27 25   {} 27 25   {} 29 26
  {} 29 26   {} 31 27   {} 32 28   {} 32 28   {} 34 29   {} 35 30   {} 36 31
  {} 37 32   {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 42 36   {} 43 37
  {} 43 37   {} 45 38   {} 46 39   {} 46 39   {} 48 40   {} 49 41   {} 50 42
  {} 51 43   {} 52 44   {} 52 44   {} 54 45   {} 55 46   {} 56 47   {} 57 48
  {} 58 49   {} 59 50   {} 60 51   {} 61 52   {} 62 53   {} 63 54   {} 64 55
  {} 64 55   {} 66 56   {} 67 57   {} 68 58   {} 69 59   {} 70 60   {} 71 61
  {} 72 62   {} 73 63   {} 73 63   {} 75 64   {} 76 65   {} 77 66   {} 78 67
  {} 78 67   {} 78 67   {} 81 68   {} 82 69   {} 83 70   {} 84 71   {} 85 72
  {} 85 72   {} 87 73   {} 88 74   {} 89 75}

do_execsql_test 5.3.14.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {963 929 6   979 102 82   979 102 82   979 102 82   979 102 82   979 102 82
  979 102 83   979 113 80   979 113 81   979 113 82   979 133 79   979 148 78
  979 158 76   979 158 77   979 160 76   979 208 75   979 223 74   979 224 73
  979 234 72   979 238 71   979 239 70   979 247 69   979 250 68   979 252 67
  979 256 66   979 257 65   979 295 64   979 309 63   979 330 63   979 335 61
  979 336 60   979 346 59   979 354 58   979 355 56   979 355 58   979 393 55
  979 393 56   979 398 54   979 399 52   979 399 53   979 412 52   979 421 51
  979 430 50   979 443 49   979 480 47   979 480 48   979 572 46   979 574 46
  979 607 44   979 618 42   979 618 43   979 627 41   979 629 40   979 629 40
  979 633 39   979 634 38   979 652 37   979 660 36   979 667 34   979 667 35
  979 670 34   979 671 33   979 683 32   979 705 31   979 711 30   979 716 29
  979 726 28   979 730 27   979 759 26   979 762 25   979 768 23   979 768 24
  979 777 22   979 786 21   979 790 20   979 792 19   979 794 18   979 805 17
  979 822 16   979 839 15   979 839 15   979 840 13   979 844 12   979 845 11
  979 870 8   979 870 9   979 870 10   979 899 8   979 911 7}

do_execsql_test 5.3.14.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE GROUP  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {2851 89 89   3778 88 88   4681 87 87   5556 83 83   5574 82 82   5586 81 81
  5640 84 84   5640 85 85   5640 86 86   7324 80 80   8123 77 77   8129 73 73
  8129 74 74   8163 78 78   8163 79 79   8940 71 71   8968 75 75   8968 76 76
  9727 66 66   9745 69 69   9745 70 70   9745 72 72   10504 65 65
  10504 67 67   10504 68 68   11215 64 64   11844 62 62   11920 63 63
  13274 60 60   13274 61 61   13897 58 58   13903 57 57   13925 56 56
  13937 55 55   13941 59 59   15203 53 53   15241 54 54   15832 52 52
  17100 48 48   17104 46 46   17104 47 47   17106 45 45   17126 49 49
  17126 50 50   17126 51 51   17569 42 42   17733 44 44   18176 43 43
  18597 40 40   18597 41 41   18952 37 37   18996 39 39   19395 38 38
  19760 35 35   19788 36 36   20492 32 32   20492 33 33   20498 30 30
  20536 34 34   20833 29 29   20871 28 28   20891 31 31   21180 27 27
  21752 23 23   21830 26 26   22025 21 21   22087 22 22   22087 24 24
  22087 25 25   22278 20 20   22316 19 19   22549 15 15   22557 14 14
  22573 17 17   22573 18 18   22706 10 10   22796 11 11   22796 12 12
  22796 13 13   22796 16 16   23022 4 4   23042 2 2   23042 3 3   23042 9 9
  23155 1 1   23155 5 5   23155 6 6   23155 7 7   23155 8 8}

do_execsql_test 5.4.1.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 1   113 113 1   133 133 1   148 148 1   158 158 0
  158 158 1   160 160 1   208 208 1   223 223 1   224 224 1   234 234 1
  238 238 1   239 239 1   247 247 1   250 250 1   252 252 1   256 256 1
  257 257 1   295 295 1   309 309 1   330 330 1   335 335 1   336 336 1
  346 346 1   354 354 1   355 355 0   355 355 1   393 393 1   393 393 1
  398 398 1   399 399 0   399 399 1   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 1   480 480 1   572 572 1   574 574 1   607 607 1
  618 618 1   618 618 1   627 627 1   629 629 0   629 629 1   633 633 1
  634 634 1   652 652 1   660 660 1   667 667 0   667 667 1   670 670 1
  671 671 1   683 683 1   705 705 1   711 711 1   716 716 1   726 726 1
  730 730 1   759 759 1   762 762 1   768 768 1   768 768 1   777 777 1
  786 786 1   790 790 1   792 792 1   794 794 1   805 805 1   822 822 1
  839 839 1   839 839 1   840 840 1   844 844 1   845 845 1   870 870 0
  870 870 1   870 870 1   899 899 1   911 911 1   929 929 1   934 934 1
  938 938 1   938 938 1   959 959 1   963 963 1   979 979 1}

do_execsql_test 5.4.1.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  113 1 1   113 1 1   133 1 1   223 1 1   239 1 1   247 1 1   257 1 1
  295 1 1   309 1 1   335 1 1   355 1 1   355 1 1   393 1 1   393 1 1
  399 1 1   399 1 1   421 1 1   443 1 1   607 1 1   627 1 1   629 1 1
  629 1 1   633 1 1   667 1 1   667 1 1   671 1 1   683 1 1   705 1 1
  711 1 1   759 1 1   777 1 1   805 1 1   839 1 1   839 1 1   845 1 1
  899 1 1   911 1 1   929 1 1   959 1 1   963 1 1   979 1 1}

do_execsql_test 5.4.2.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {113 113 1   234 234 1   257 257 1   336 336 1   354 354 1   768 768 1
  839 839 1   839 839 1   899 113 10   899 113 10   899 113 10   899 113 10
  899 113 10   899 113 10   899 113 10   899 113 17   899 113 17   899 113 17
  899 113 17   899 113 17   899 113 17   899 113 17   899 899 1   963 113 17
  979 102 34   979 102 45   979 102 45   979 102 45   979 102 45   979 102 45
  979 102 50   979 102 50   979 102 50   979 102 50   979 102 50   979 102 50
  979 102 50   979 102 57   979 102 57   979 102 57   979 102 57   979 102 57
  979 102 57   979 102 63   979 102 63   979 102 63   979 102 63   979 102 63
  979 102 63   979 102 63   979 102 63   979 102 63   979 102 63   979 102 63
  979 102 63   979 102 63   979 102 76   979 102 76   979 102 76   979 102 76
  979 102 76   979 102 76   979 102 76   979 102 76   979 102 83   979 102 83
  979 102 83   979 102 83   979 102 83   979 102 83   979 113 17   979 113 26
  979 113 26   979 113 26   979 113 26   979 113 26   979 113 26   979 113 26
  979 113 26   979 113 34   979 113 34   979 113 34   979 113 34   979 113 34
  979 113 34   979 113 34   979 113 34   979 113 34   979 113 34}

do_execsql_test 5.4.2.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 81 11   {} 81 11   {} 81 11   {} 81 11   113 81 11   257 81 11
  839 81 11   839 81 11   899 81 11   2947 74 10   2947 74 10   2947 74 10
  3368 74 10   3390 74 10   3618 74 10   3752 74 10   5287 65 9   5287 65 9
  5287 65 9   5287 65 9   5420 65 9   5642 65 9   5970 65 9   6250 65 9
  6266 65 9   8400 57 8   8400 57 8   8400 57 8   8400 57 8   8400 57 8
  8400 57 8   8735 57 8   9329 57 8   9664 46 7   9664 46 7   9664 46 7
  9664 46 7   9664 46 7   9664 46 7   9664 46 7   9664 46 7   9664 46 7
  9959 46 7   10331 46 7   10626 41 6   10626 41 6   10739 41 6   11255 41 6
  11403 41 6   12145 34 5   12145 34 5   12145 34 5   12145 34 5   12145 34 5
  12990 34 5   13104 34 5   13949 28 4   13949 28 4   13949 28 4   13949 28 4
  14556 28 4   14708 28 4   15315 15 3   15315 15 3   15315 15 3   15315 15 3
  15315 15 3   15315 15 3   15562 15 3   15708 15 3   15708 15 3   15714 15 3
  15948 15 3   16020 15 3   16026 15 3   18796 7 2   18796 7 2   18796 7 2
  19019 7 2   19035 7 2   19105 7 2   19423 7 2   19707 7 2   21105 1 1
  21105 1 1   21460 1 1   21504 1 1   21734 1 1   21772 1 1}

do_execsql_test 5.4.3.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 1   113 113 1   133 133 1   148 148 1   158 158 0
  158 158 1   160 160 1   208 208 1   223 223 1   224 224 1   234 234 1
  238 238 1   239 239 1   247 247 1   250 250 1   252 252 1   256 256 1
  257 257 1   295 295 1   309 309 1   330 330 1   335 335 1   336 336 1
  346 346 1   354 354 1   355 355 0   355 355 1   393 393 1   393 393 1
  398 398 1   399 399 0   399 399 1   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 1   480 480 1   572 572 1   574 574 1   607 607 1
  618 618 1   618 618 1   627 627 1   629 629 0   629 629 1   633 633 1
  634 634 1   652 652 1   660 660 1   667 667 0   667 667 1   670 670 1
  671 671 1   683 683 1   705 705 1   711 711 1   716 716 1   726 726 1
  730 730 1   759 759 1   762 762 1   768 768 1   768 768 1   777 777 1
  786 786 1   790 790 1   792 792 1   794 794 1   805 805 1   822 822 1
  839 839 1   839 839 1   840 840 1   844 844 1   845 845 1   870 870 0
  870 870 1   870 870 1   899 899 1   911 911 1   929 929 1   934 934 1
  938 938 1   938 938 1   959 959 1   963 963 1   979 979 1}

do_execsql_test 5.4.3.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  113 1 1   113 1 1   133 1 1   223 1 1   239 1 1   247 1 1   257 1 1
  295 1 1   309 1 1   335 1 1   355 1 1   355 1 1   393 1 1   393 1 1
  399 1 1   399 1 1   421 1 1   443 1 1   607 1 1   627 1 1   629 1 1
  629 1 1   633 1 1   667 1 1   667 1 1   671 1 1   683 1 1   705 1 1
  711 1 1   759 1 1   777 1 1   805 1 1   839 1 1   839 1 1   845 1 1
  899 1 1   911 1 1   929 1 1   959 1 1   963 1 1   979 1 1}

do_execsql_test 5.4.4.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST GROUPS 6 PRECEDING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {158 158 0   355 355 0   399 399 0   629 629 0   667 667 0   870 158 1
  870 158 1   870 158 1   870 158 1   870 158 1   870 158 1   870 870 0
  911 158 1   934 158 1   934 158 9   934 158 9   934 158 9   934 158 9
  934 158 9   934 158 9   934 158 9   934 158 9   934 158 9   934 158 9
  934 158 9   934 158 9   934 158 9   934 158 22   934 158 22   934 158 22
  934 158 22   934 158 22   934 158 22   934 158 28   934 158 28   934 158 28
  934 158 28   934 158 28   934 158 28   959 102 40   959 102 51   959 102 51
  959 102 51   959 102 51   959 102 51   959 102 51   959 102 51   959 102 51
  959 102 51   959 102 51   959 102 51   959 102 51   959 102 51   959 102 51
  959 102 51   959 113 35   959 113 40   959 113 40   959 113 40   959 113 40
  959 113 40   959 113 40   959 113 40   959 113 40   959 113 40   959 113 40
  959 158 28   959 158 35   959 158 35   959 158 35   959 158 35   963 102 51
  979 102 47   979 102 47   979 102 47   979 102 47   979 102 47   979 102 47
  979 102 47   979 102 48   979 102 48   979 102 48   979 102 48   979 102 48
  979 102 48   979 102 48   979 102 48   979 102 48   979 102 51}

do_execsql_test 5.4.4.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS FIRST GROUPS 6 PRECEDING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   355 1 1   399 1 1   629 1 1   667 1 1   2050 7 2
  2050 7 2   2050 7 2   2273 7 2   2289 7 2   2359 7 2   2677 7 2   2961 7 2
  4359 15 3   4359 15 3   4359 15 3   4359 15 3   4359 15 3   4359 15 3
  4606 15 3   4752 15 3   4752 15 3   4758 15 3   4992 15 3   5064 15 3
  5070 15 3   7840 28 4   7840 28 4   7840 28 4   7840 28 4   8447 28 4
  8599 28 4   9206 34 5   9206 34 5   9206 34 5   9206 34 5   9206 34 5
  10028 74 10   10028 74 10   10028 74 10   10051 34 5   10165 34 5
  10396 65 9   10396 65 9   10396 65 9   10396 65 9   10449 74 10
  10471 74 10   10529 65 9   10699 74 10   10751 65 9   10833 74 10
  11002 81 11   11002 81 11   11002 81 11   11002 81 11   11010 41 6
  11010 41 6   11079 65 9   11115 81 11   11123 41 6   11259 81 11
  11359 65 9   11375 65 9   11441 57 8   11441 57 8   11441 57 8   11441 57 8
  11441 57 8   11441 57 8   11639 41 6   11776 57 8   11787 41 6
  11841 81 11   11841 81 11   11901 81 11   12370 57 8   12529 46 7
  12529 46 7   12529 46 7   12529 46 7   12529 46 7   12529 46 7   12529 46 7
  12529 46 7   12529 46 7   12824 46 7   13196 46 7}

do_execsql_test 5.4.5.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 1   113 113 1   133 133 1   148 148 1   160 158 1
  160 158 2   160 158 2   208 208 1   224 223 2   224 223 2   239 234 3
  239 234 3   239 234 3   252 247 3   257 247 5   257 247 5   257 250 4
  257 252 3   295 295 1   309 309 1   336 330 3   336 330 3   336 330 3
  346 346 1   355 354 1   355 354 2   355 354 2   399 393 3   399 393 3
  399 393 3   399 393 4   399 393 4   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 1   480 480 1   574 572 2   574 572 2   607 607 1
  618 618 1   618 618 1   634 627 3   634 627 4   634 627 4   634 627 4
  634 629 3   652 652 1   667 660 2   671 667 2   671 667 3   671 667 3
  671 667 3   683 683 1   711 705 2   716 705 3   716 711 2   730 726 2
  730 726 2   762 759 2   768 759 4   768 762 2   768 762 2   777 777 1
  792 786 3   794 786 4   794 786 4   794 790 3   805 805 1   822 822 1
  845 839 4   845 839 4   845 839 5   845 839 5   845 839 5   870 870 0
  870 870 1   870 870 1   899 899 1   911 911 1   934 929 2   938 929 4
  938 934 2   938 934 2   963 959 2   963 959 2   979 979 1}

do_execsql_test 5.4.5.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 25 23   {} 34 29
  {} 36 31   {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 43 37   {} 43 37
  {} 50 42   {} 60 51   {} 61 52   {} 64 55   {} 64 55   {} 67 57   {} 68 58
  {} 69 59   {} 70 60   {} 72 62   {} 78 67   {} 78 67   {} 78 67   {} 85 72
  {} 85 72   113 2 2   113 2 2   133 4 3   223 10 8   223 11 9   239 12 10
  239 13 11   239 14 12   247 15 13   257 18 16   257 19 17   295 20 18
  309 21 19   335 22 20   335 23 21   335 24 22   355 27 25   355 27 25
  421 35 30   443 37 32   504 16 14   504 17 15   607 42 36   683 56 47
  710 26 24   711 59 50   759 62 53   759 63 54   777 66 56   805 71 61
  899 81 68   911 82 69   929 83 70   929 84 71   979 89 75   1185 32 28
  1185 32 28   1191 29 26   1191 29 26   1334 51 43   1338 52 44   1338 52 44
  1416 57 48   1416 58 49   1584 31 27   1684 73 63   1684 73 63   1889 46 39
  1889 46 39   1891 49 41   1922 87 73   1922 88 74   2005 54 45   2005 55 46
  2518 45 38   2518 48 40   2523 75 64   2523 76 65   2523 77 66}

do_execsql_test 5.4.6.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 1   113 113 1   133 133 1   148 148 1   158 158 0
  158 158 1   160 160 1   208 208 1   223 223 1   224 224 1   234 234 1
  238 238 1   239 239 1   247 247 1   250 250 1   252 252 1   256 256 1
  257 257 1   295 295 1   309 309 1   330 330 1   335 335 1   336 336 1
  346 346 1   354 354 1   355 355 0   355 355 1   393 393 1   393 393 1
  398 398 1   399 399 0   399 399 1   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 1   480 480 1   572 572 1   574 574 1   607 607 1
  618 618 1   618 618 1   627 627 1   629 629 0   629 629 1   633 633 1
  634 634 1   652 652 1   660 660 1   667 667 0   667 667 1   670 670 1
  671 671 1   683 683 1   705 705 1   711 711 1   716 716 1   726 726 1
  730 730 1   759 759 1   762 762 1   768 768 1   768 768 1   777 777 1
  786 786 1   790 790 1   792 792 1   794 794 1   805 805 1   822 822 1
  839 839 1   839 839 1   840 840 1   844 844 1   845 845 1   870 870 0
  870 870 1   870 870 1   899 899 1   911 911 1   929 929 1   934 934 1
  938 938 1   938 938 1   959 959 1   963 963 1   979 979 1}

do_execsql_test 5.4.6.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 11 9   {} 12 10
  {} 13 11   {} 16 14   {} 17 15   {} 18 16   {} 22 20   {} 24 22   {} 25 23
  {} 26 24   {} 31 27   {} 34 29   {} 36 31   {} 38 33   {} 38 33   {} 40 34
  {} 41 35   {} 43 37   {} 43 37   {} 49 41   {} 50 42   {} 51 43   {} 54 45
  {} 59 50   {} 60 51   {} 61 52   {} 63 54   {} 64 55   {} 64 55   {} 67 57
  {} 68 58   {} 69 59   {} 70 60   {} 72 62   {} 75 64   {} 76 65   {} 78 67
  {} 78 67   {} 78 67   {} 84 71   {} 85 72   {} 85 72   113 2 2   113 2 2
  133 4 3   223 10 8   239 14 12   247 15 13   257 19 17   295 20 18
  309 21 19   335 23 21   355 27 25   355 27 25   393 29 26   393 29 26
  399 32 28   399 32 28   421 35 30   443 37 32   607 42 36   627 45 38
  629 46 39   629 46 39   633 48 40   667 52 44   667 52 44   671 55 46
  683 56 47   705 57 48   711 58 49   759 62 53   777 66 56   805 71 61
  839 73 63   839 73 63   845 77 66   899 81 68   911 82 69   929 83 70
  959 87 73   963 88 74   979 89 75}

do_execsql_test 5.4.7.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 113 81   979 113 82   979 133 80   979 148 79   979 158 77
  979 158 78   979 160 77   979 208 76   979 223 75   979 224 74   979 234 73
  979 238 72   979 239 71   979 247 70   979 250 69   979 252 68   979 256 67
  979 257 66   979 295 65   979 309 64   979 330 63   979 335 62   979 336 61
  979 346 60   979 354 59   979 355 58   979 355 58   979 393 56   979 393 57
  979 398 55   979 399 54   979 399 54   979 412 53   979 421 52   979 430 51
  979 443 50   979 480 48   979 480 49   979 572 47   979 574 46   979 607 45
  979 618 43   979 618 44   979 627 42   979 629 41   979 629 41   979 633 40
  979 634 39   979 652 38   979 660 37   979 667 36   979 667 36   979 670 35
  979 671 34   979 683 33   979 705 32   979 711 31   979 716 30   979 726 29
  979 730 28   979 759 27   979 762 26   979 768 24   979 768 25   979 777 23
  979 786 22   979 790 21   979 792 20   979 794 19   979 805 18   979 822 17
  979 839 15   979 839 16   979 840 14   979 844 13   979 845 12   979 870 10
  979 870 11   979 870 11   979 899 9   979 911 8   979 929 7}

do_execsql_test 5.4.7.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS FIRST, b NULLS FIRST, a NULLS FIRST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {3830 89 89   4741 88 88   5640 84 84   5640 85 85   5640 86 86   5640 87 87
  6485 81 81   6485 82 82   6485 83 83   7324 80 80   8163 78 78   8163 79 79
  8968 73 73   8968 74 74   8968 75 75   8968 76 76   8968 77 77   9745 69 69
  9745 70 70   9745 71 71   9745 72 72   10504 65 65   10504 66 66
  10504 67 67   10504 68 68   11215 64 64   11920 63 63   12603 62 62
  13274 60 60   13274 61 61   13941 59 59   14608 55 55   14608 56 56
  14608 57 57   14608 58 58   15241 54 54   15870 53 53   16499 52 52
  17126 49 49   17126 50 50   17126 51 51   17733 44 44   17733 45 45
  17733 46 46   17733 47 47   17733 48 48   18176 42 42   18176 43 43
  18597 40 40   18597 41 41   18996 39 39   19395 37 37   19395 38 38
  19788 36 36   20181 35 35   20536 34 34   20891 30 30   20891 31 31
  20891 32 32   20891 33 33   21226 28 28   21226 29 29   21535 27 27
  21830 26 26   22087 22 22   22087 23 23   22087 24 24   22087 25 25
  22334 21 21   22573 17 17   22573 18 18   22573 19 19   22573 20 20
  22796 11 11   22796 12 12   22796 13 13   22796 14 14   22796 15 15
  22796 16 16   22929 10 10   23042 9 9   23155 1 1   23155 2 2   23155 3 3
  23155 4 4   23155 5 5   23155 6 6   23155 7 7   23155 8 8}

do_execsql_test 5.4.8.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 1   113 113 1   133 133 1   148 148 1   158 158 0
  158 158 1   160 160 1   208 208 1   223 223 1   224 224 1   234 234 1
  238 238 1   239 239 1   247 247 1   250 250 1   252 252 1   256 256 1
  257 257 1   295 295 1   309 309 1   330 330 1   335 335 1   336 336 1
  346 346 1   354 354 1   355 355 0   355 355 1   393 393 1   393 393 1
  398 398 1   399 399 0   399 399 1   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 1   480 480 1   572 572 1   574 574 1   607 607 1
  618 618 1   618 618 1   627 627 1   629 629 0   629 629 1   633 633 1
  634 634 1   652 652 1   660 660 1   667 667 0   667 667 1   670 670 1
  671 671 1   683 683 1   705 705 1   711 711 1   716 716 1   726 726 1
  730 730 1   759 759 1   762 762 1   768 768 1   768 768 1   777 777 1
  786 786 1   790 790 1   792 792 1   794 794 1   805 805 1   822 822 1
  839 839 1   839 839 1   840 840 1   844 844 1   845 845 1   870 870 0
  870 870 1   870 870 1   899 899 1   911 911 1   929 929 1   934 934 1
  938 938 1   938 938 1   959 959 1   963 963 1   979 979 1}

do_execsql_test 5.4.8.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  113 1 1   113 1 1   133 1 1   223 1 1   239 1 1   247 1 1   257 1 1
  295 1 1   309 1 1   335 1 1   355 1 1   355 1 1   393 1 1   393 1 1
  399 1 1   399 1 1   421 1 1   443 1 1   607 1 1   627 1 1   629 1 1
  629 1 1   633 1 1   667 1 1   667 1 1   671 1 1   683 1 1   705 1 1
  711 1 1   759 1 1   777 1 1   805 1 1   839 1 1   839 1 1   845 1 1
  899 1 1   911 1 1   929 1 1   959 1 1   963 1 1   979 1 1}

do_execsql_test 5.4.9.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {158 158 0   355 355 0   399 399 0   629 629 0   667 667 0   870 113 1
  870 158 1   870 158 1   870 158 1   870 158 1   870 158 1   870 158 1
  870 158 1   870 870 0   899 113 10   899 113 10   899 113 10   899 113 10
  899 113 10   899 113 10   899 113 10   899 113 17   899 113 17   899 113 17
  899 113 17   899 113 17   899 113 17   899 113 17   899 158 1   963 113 17
  979 102 34   979 102 45   979 102 45   979 102 45   979 102 45   979 102 45
  979 102 50   979 102 50   979 102 50   979 102 50   979 102 50   979 102 50
  979 102 50   979 102 57   979 102 57   979 102 57   979 102 57   979 102 57
  979 102 57   979 102 63   979 102 63   979 102 63   979 102 63   979 102 63
  979 102 63   979 102 63   979 102 63   979 102 63   979 102 63   979 102 63
  979 102 63   979 102 63   979 102 76   979 102 76   979 102 76   979 102 76
  979 102 76   979 102 76   979 102 76   979 102 76   979 113 17   979 113 26
  979 113 26   979 113 26   979 113 26   979 113 26   979 113 26   979 113 26
  979 113 26   979 113 34   979 113 34   979 113 34   979 113 34   979 113 34
  979 113 34   979 113 34   979 113 34   979 113 34   979 113 34}

do_execsql_test 5.4.9.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 84 11   {} 84 11   355 84 11   399 84 11   629 84 11   667 84 11
  2050 75 10   2050 75 10   2050 75 10   2050 75 10   2163 75 10   2307 75 10
  2889 75 10   2889 75 10   2949 75 10   4997 68 9   4997 68 9   4997 68 9
  5418 68 9   5440 68 9   5668 68 9   5802 68 9   7337 59 8   7337 59 8
  7337 59 8   7337 59 8   7470 59 8   7692 59 8   8020 59 8   8300 59 8
  8316 59 8   10450 51 7   10450 51 7   10450 51 7   10450 51 7   10450 51 7
  10450 51 7   10785 51 7   11379 51 7   11714 40 6   11714 40 6   11714 40 6
  11714 40 6   11714 40 6   11714 40 6   11714 40 6   11714 40 6   11714 40 6
  12009 40 6   12381 40 6   12676 35 5   12676 35 5   12789 35 5   13305 35 5
  13453 35 5   14195 28 4   14195 28 4   14195 28 4   14195 28 4   14195 28 4
  15040 28 4   15154 28 4   15999 22 3   15999 22 3   15999 22 3   15999 22 3
  16606 22 3   16758 22 3   17365 9 2   17365 9 2   17365 9 2   17365 9 2
  17365 9 2   17365 9 2   17612 9 2   17758 9 2   17758 9 2   17764 9 2
  17998 9 2   18070 9 2   18076 9 2   20846 1 1   20846 1 1   20846 1 1
  21069 1 1   21085 1 1   21155 1 1   21473 1 1   21757 1 1}

do_execsql_test 5.4.10.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 1   113 113 1   133 133 1   148 148 1   158 158 0
  158 158 1   160 160 1   208 208 1   223 223 1   224 224 1   234 234 1
  238 238 1   239 239 1   247 247 1   250 250 1   252 252 1   256 256 1
  257 257 1   295 295 1   309 309 1   330 330 1   335 335 1   336 336 1
  346 346 1   354 354 1   355 355 0   355 355 1   393 393 1   393 393 1
  398 398 1   399 399 0   399 399 1   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 1   480 480 1   572 572 1   574 574 1   607 607 1
  618 618 1   618 618 1   627 627 1   629 629 0   629 629 1   633 633 1
  634 634 1   652 652 1   660 660 1   667 667 0   667 667 1   670 670 1
  671 671 1   683 683 1   705 705 1   711 711 1   716 716 1   726 726 1
  730 730 1   759 759 1   762 762 1   768 768 1   768 768 1   777 777 1
  786 786 1   790 790 1   792 792 1   794 794 1   805 805 1   822 822 1
  839 839 1   839 839 1   840 840 1   844 844 1   845 845 1   870 870 0
  870 870 1   870 870 1   899 899 1   911 911 1   929 929 1   934 934 1
  938 938 1   938 938 1   959 959 1   963 963 1   979 979 1}

do_execsql_test 5.4.10.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  PARTITION BY coalesce(a, '') 
        RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1   {} 1 1
  113 1 1   113 1 1   133 1 1   223 1 1   239 1 1   247 1 1   257 1 1
  295 1 1   309 1 1   335 1 1   355 1 1   355 1 1   393 1 1   393 1 1
  399 1 1   399 1 1   421 1 1   443 1 1   607 1 1   627 1 1   629 1 1
  629 1 1   633 1 1   667 1 1   667 1 1   671 1 1   683 1 1   705 1 1
  711 1 1   759 1 1   777 1 1   805 1 1   839 1 1   839 1 1   845 1 1
  899 1 1   911 1 1   929 1 1   959 1 1   963 1 1   979 1 1}

do_execsql_test 5.4.11.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST GROUPS 6 PRECEDING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {223 223 1   239 239 1   309 309 1   572 572 1   627 627 1   870 870 1
  911 911 1   934 158 22   934 158 28   934 158 28   934 158 28   934 158 28
  934 158 28   934 158 28   934 223 9   934 223 9   934 223 9   934 223 9
  934 223 9   934 223 9   934 223 9   934 223 9   934 223 9   934 223 9
  934 223 9   934 223 9   934 223 9   934 223 22   934 223 22   934 223 22
  934 223 22   934 223 22   934 934 1   959 102 40   959 102 51   959 102 51
  959 102 51   959 102 51   959 102 51   959 102 51   959 102 51   959 102 51
  959 102 51   959 102 51   959 102 51   959 102 51   959 102 51   959 102 51
  959 102 51   959 113 35   959 113 40   959 113 40   959 113 40   959 113 40
  959 113 40   959 113 40   959 113 40   959 113 40   959 113 40   959 113 40
  959 158 28   959 158 35   959 158 35   959 158 35   959 158 35   963 102 51
  979 102 47   979 102 47   979 102 47   979 102 47   979 102 47   979 102 47
  979 102 47   979 102 48   979 102 48   979 102 48   979 102 48   979 102 48
  979 102 48   979 102 48   979 102 48   979 102 48   979 102 49   979 102 49
  979 102 49   979 102 49   979 102 49   979 102 49   979 102 51}

do_execsql_test 5.4.11.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY a NULLS LAST GROUPS 6 PRECEDING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 1 1   {} 1 1   223 1 1   239 1 1   309 1 1   627 1 1   911 1 1
  2309 9 2   2309 9 2   2309 9 2   2309 9 2   2309 9 2   2309 9 2   2556 9 2
  2702 9 2   2702 9 2   2708 9 2   2942 9 2   3014 9 2   3020 9 2   5790 22 3
  5790 22 3   5790 22 3   5790 22 3   6397 22 3   6549 22 3   7156 28 4
  7156 28 4   7156 28 4   7156 28 4   7156 28 4   8001 28 4   8115 28 4
  8960 35 5   8960 35 5   9073 35 5   9589 35 5   9737 35 5   10028 68 9
  10028 68 9   10028 68 9   10396 59 8   10396 59 8   10396 59 8   10396 59 8
  10449 68 9   10471 68 9   10479 40 6   10479 40 6   10479 40 6   10479 40 6
  10479 40 6   10479 40 6   10479 40 6   10479 40 6   10479 40 6   10529 59 8
  10699 68 9   10751 59 8   10774 40 6   10833 68 9   11002 75 10
  11002 75 10   11002 75 10   11002 75 10   11079 59 8   11115 75 10
  11146 40 6   11259 75 10   11359 59 8   11375 59 8   11441 51 7
  11441 51 7   11441 51 7   11441 51 7   11441 51 7   11441 51 7   11776 51 7
  11841 75 10   11841 75 10   11901 75 10   12145 84 11   12145 84 11
  12370 51 7   12500 84 11   12544 84 11   12774 84 11   12812 84 11}

do_execsql_test 5.4.12.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 1   113 113 1   133 133 1   148 148 1   160 158 1
  160 158 2   160 158 2   208 208 1   224 223 2   224 223 2   239 234 3
  239 234 3   239 234 3   252 247 3   257 247 5   257 247 5   257 250 4
  257 252 3   295 295 1   309 309 1   336 330 3   336 330 3   336 330 3
  346 346 1   355 354 1   355 354 2   355 354 2   399 393 3   399 393 3
  399 393 3   399 393 4   399 393 4   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 1   480 480 1   574 572 2   574 572 2   607 607 1
  618 618 1   618 618 1   634 627 3   634 627 4   634 627 4   634 627 4
  634 629 3   652 652 1   667 660 2   671 667 2   671 667 3   671 667 3
  671 667 3   683 683 1   711 705 2   716 705 3   716 711 2   730 726 2
  730 726 2   762 759 2   768 759 4   768 762 2   768 762 2   777 777 1
  792 786 3   794 786 4   794 786 4   794 790 3   805 805 1   822 822 1
  845 839 4   845 839 4   845 839 5   845 839 5   845 839 5   870 870 0
  870 870 1   870 870 1   899 899 1   911 911 1   934 929 2   938 929 4
  938 934 2   938 934 2   963 959 2   963 959 2   979 979 1}

do_execsql_test 5.4.12.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 6 PRECEDING AND 7 FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 25 23   {} 34 29
  {} 36 31   {} 38 33   {} 38 33   {} 40 34   {} 41 35   {} 43 37   {} 43 37
  {} 50 42   {} 60 51   {} 61 52   {} 64 55   {} 64 55   {} 67 57   {} 68 58
  {} 69 59   {} 70 60   {} 72 62   {} 78 67   {} 78 67   {} 78 67   {} 85 72
  {} 85 72   113 2 2   113 2 2   133 4 3   223 10 8   223 11 9   239 12 10
  239 13 11   239 14 12   247 15 13   257 18 16   257 19 17   295 20 18
  309 21 19   335 22 20   335 23 21   335 24 22   355 27 25   355 27 25
  421 35 30   443 37 32   504 16 14   504 17 15   607 42 36   683 56 47
  710 26 24   711 59 50   759 62 53   759 63 54   777 66 56   805 71 61
  899 81 68   911 82 69   929 83 70   929 84 71   979 89 75   1185 32 28
  1185 32 28   1191 29 26   1191 29 26   1334 51 43   1338 52 44   1338 52 44
  1416 57 48   1416 58 49   1584 31 27   1684 73 63   1684 73 63   1889 46 39
  1889 46 39   1891 49 41   1922 87 73   1922 88 74   2005 54 45   2005 55 46
  2518 45 38   2518 48 40   2523 75 64   2523 76 65   2523 77 66}

do_execsql_test 5.4.13.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {102 102 1   113 113 1   113 113 1   133 133 1   148 148 1   158 158 0
  158 158 1   160 160 1   208 208 1   223 223 1   224 224 1   234 234 1
  238 238 1   239 239 1   247 247 1   250 250 1   252 252 1   256 256 1
  257 257 1   295 295 1   309 309 1   330 330 1   335 335 1   336 336 1
  346 346 1   354 354 1   355 355 0   355 355 1   393 393 1   393 393 1
  398 398 1   399 399 0   399 399 1   412 412 1   421 421 1   430 430 1
  443 443 1   480 480 1   480 480 1   572 572 1   574 574 1   607 607 1
  618 618 1   618 618 1   627 627 1   629 629 0   629 629 1   633 633 1
  634 634 1   652 652 1   660 660 1   667 667 0   667 667 1   670 670 1
  671 671 1   683 683 1   705 705 1   711 711 1   716 716 1   726 726 1
  730 730 1   759 759 1   762 762 1   768 768 1   768 768 1   777 777 1
  786 786 1   790 790 1   792 792 1   794 794 1   805 805 1   822 822 1
  839 839 1   839 839 1   840 840 1   844 844 1   845 845 1   870 870 0
  870 870 1   870 870 1   899 899 1   911 911 1   929 929 1   934 934 1
  938 938 1   938 938 1   959 959 1   963 963 1   979 979 1}

do_execsql_test 5.4.13.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST RANGE BETWEEN 0 PRECEDING AND 0 FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {{} 1 1   {} 5 4   {} 6 5   {} 6 5   {} 8 6   {} 9 7   {} 11 9   {} 12 10
  {} 13 11   {} 16 14   {} 17 15   {} 18 16   {} 22 20   {} 24 22   {} 25 23
  {} 26 24   {} 31 27   {} 34 29   {} 36 31   {} 38 33   {} 38 33   {} 40 34
  {} 41 35   {} 43 37   {} 43 37   {} 49 41   {} 50 42   {} 51 43   {} 54 45
  {} 59 50   {} 60 51   {} 61 52   {} 63 54   {} 64 55   {} 64 55   {} 67 57
  {} 68 58   {} 69 59   {} 70 60   {} 72 62   {} 75 64   {} 76 65   {} 78 67
  {} 78 67   {} 78 67   {} 84 71   {} 85 72   {} 85 72   113 2 2   113 2 2
  133 4 3   223 10 8   239 14 12   247 15 13   257 19 17   295 20 18
  309 21 19   335 23 21   355 27 25   355 27 25   393 29 26   393 29 26
  399 32 28   399 32 28   421 35 30   443 37 32   607 42 36   627 45 38
  629 46 39   629 46 39   633 48 40   667 52 44   667 52 44   671 55 46
  683 56 47   705 57 48   711 58 49   759 62 53   777 66 56   805 71 61
  839 73 63   839 73 63   845 77 66   899 81 68   911 82 69   929 83 70
  959 87 73   963 88 74   979 89 75}

do_execsql_test 5.4.14.1 {
  SELECT max(c) OVER win,
             min(c) OVER win,
             count(a) OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {979 102 83   979 102 83   979 102 83   979 102 83   979 102 83   979 102 83
  979 102 83   979 113 81   979 113 82   979 133 80   979 148 79   979 158 77
  979 158 78   979 160 77   979 208 76   979 223 75   979 224 74   979 234 73
  979 238 72   979 239 71   979 247 70   979 250 69   979 252 68   979 256 67
  979 257 66   979 295 65   979 309 64   979 330 63   979 335 62   979 336 61
  979 346 60   979 354 59   979 355 57   979 355 58   979 393 56   979 393 57
  979 398 55   979 399 53   979 399 54   979 412 53   979 421 52   979 430 51
  979 443 50   979 480 48   979 480 49   979 572 47   979 574 46   979 607 45
  979 618 43   979 618 44   979 627 42   979 629 40   979 629 41   979 633 40
  979 634 39   979 652 38   979 660 37   979 667 35   979 667 36   979 670 35
  979 671 34   979 683 33   979 705 32   979 711 31   979 716 30   979 726 29
  979 730 28   979 759 27   979 762 26   979 768 24   979 768 25   979 777 23
  979 786 22   979 790 21   979 792 20   979 794 19   979 805 18   979 822 17
  979 839 15   979 839 16   979 840 14   979 844 13   979 845 12   979 870 9
  979 870 10   979 870 11   979 899 9   979 911 8   979 929 7}

do_execsql_test 5.4.14.2 {
  SELECT sum(c) FILTER (WHERE (c%2)!=0) OVER win,
             rank() OVER win,
             dense_rank() OVER win
      FROM t3
      WINDOW win AS (  ORDER BY c NULLS LAST, b NULLS LAST, a NULLS LAST
        ROWS BETWEEN 6 PRECEDING AND UNBOUNDED FOLLOWING   EXCLUDE TIES  )
      ORDER BY 1 NULLS FIRST, 2 NULLS FIRST, 3 NULLS FIRST
} {3830 89 89   4741 88 88   5640 84 84   5640 85 85   5640 86 86   5640 87 87
  6485 81 81   6485 82 82   6485 83 83   7324 80 80   8163 78 78   8163 79 79
  8968 73 73   8968 74 74   8968 75 75   8968 76 76   8968 77 77   9745 69 69
  9745 70 70   9745 71 71   9745 72 72   10504 65 65   10504 66 66
  10504 67 67   10504 68 68   11215 64 64   11920 63 63   12603 62 62
  13274 60 60   13274 61 61   13941 59 59   14608 55 55   14608 56 56
  14608 57 57   14608 58 58   15241 54 54   15870 53 53   16499 52 52
  17126 49 49   17126 50 50   17126 51 51   17733 44 44   17733 45 45
  17733 46 46   17733 47 47   17733 48 48   18176 42 42   18176 43 43
  18597 40 40   18597 41 41   18996 39 39   19395 37 37   19395 38 38
  19788 36 36   20181 35 35   20536 34 34   20891 30 30   20891 31 31
  20891 32 32   20891 33 33   21226 28 28   21226 29 29   21535 27 27
  21830 26 26   22087 22 22   22087 23 23   22087 24 24   22087 25 25
  22334 21 21   22573 17 17   22573 18 18   22573 19 19   22573 20 20
  22796 11 11   22796 12 12   22796 13 13   22796 14 14   22796 15 15
  22796 16 16   22929 10 10   23042 9 9   23155 1 1   23155 2 2   23155 3 3
  23155 4 4   23155 5 5   23155 6 6   23155 7 7   23155 8 8}

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

do_execsql_test 6.0 {
  DROP TABLE IF EXISTS t2;
  CREATE TABLE t2(a TEXT, b INTEGER);
  INSERT INTO t2 VALUES('A', NULL);
  INSERT INTO t2 VALUES('B', NULL);
  INSERT INTO t2 VALUES('C', 1);
} {}

do_execsql_test 6.1 {
  SELECT group_concat(a, '.') OVER (
    ORDER BY b NULLS FIRST RANGE BETWEEN 7 PRECEDING AND 2 PRECEDING
  )
  FROM t2
} {A.B   A.B   {}}

do_execsql_test 6.2 {
  SELECT group_concat(a, '.') OVER (
    ORDER BY b DESC NULLS LAST RANGE BETWEEN 7 PRECEDING AND 2 PRECEDING
  )
  FROM t2
} {{}   A.B   A.B}

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

do_execsql_test 7.0 {
  DROP TABLE IF EXISTS t2;
  CREATE TABLE t2(a INTEGER, b INTEGER);

  INSERT INTO t2 VALUES(1, 65);
  INSERT INTO t2 VALUES(2, NULL);
  INSERT INTO t2 VALUES(3, NULL);
  INSERT INTO t2 VALUES(4, NULL);
  INSERT INTO t2 VALUES(5, 66);
  INSERT INTO t2 VALUES(6, 67);
} {}

do_execsql_test 7.1.1 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 6 FOLLOWING AND UNBOUNDED FOLLOWING
  );
} {9   9   9   9   9   9}

do_execsql_test 7.1.2 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
  );
} {{}   {}   {}   9   9   9}

do_execsql_test 7.1.3 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
  );
} {{}   {}   {}   9   9   9}

do_execsql_test 7.1.4 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
  );
} {9   9   9   {}   {}   {}}

do_execsql_test 7.1.5 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
  );
} {9   9   9   {}   {}   {}}

do_execsql_test 7.1.6 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 1000 PRECEDING AND 2 PRECEDING
  );
} {{}   {}   1   9   9   9}

do_execsql_test 7.1.7 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
  );
} {{}   {}   {}   9   9   9}

do_execsql_test 7.1.8 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 1000 PRECEDING AND 2000 PRECEDING
  );
} {9   9   9   {}   {}   {}}

do_execsql_test 7.1.9 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
  );
} {9   9   9   {}   {}   {}}

do_execsql_test 7.2.1 {
  SELECT min (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 6 FOLLOWING AND UNBOUNDED FOLLOWING
  );
} {2   2   2   2   2   2}

do_execsql_test 7.2.2 {
  SELECT min (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
  );
} {{}   {}   {}   2   2   2}

do_execsql_test 7.2.3 {
  SELECT min (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
  );
} {{}   {}   {}   2   2   2}

do_execsql_test 7.2.4 {
  SELECT min (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
  );
} {2   2   2   {}   {}   {}}

do_execsql_test 7.2.5 {
  SELECT min (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
  );
} {2   2   2   {}   {}   {}}

do_execsql_test 7.2.6 {
  SELECT min (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 1000 PRECEDING AND 2 PRECEDING
  );
} {{}   {}   1   2   2   2}

do_execsql_test 7.2.7 {
  SELECT min (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
  );
} {{}   {}   {}   2   2   2}

do_execsql_test 7.2.8 {
  SELECT min (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 1000 PRECEDING AND 2000 PRECEDING
  );
} {2   2   2   {}   {}   {}}

do_execsql_test 7.2.9 {
  SELECT min (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
  );
} {2   2   2   {}   {}   {}}

do_execsql_test 7.3.1 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 6 FOLLOWING AND UNBOUNDED FOLLOWING
  );
} {9   9   9   9   9   9}

do_execsql_test 7.3.2 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
  );
} {{}   {}   {}   9   9   9}

do_execsql_test 7.3.3 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
  );
} {{}   {}   {}   9   9   9}

do_execsql_test 7.3.4 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
  );
} {9   9   9   {}   {}   {}}

do_execsql_test 7.3.5 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
  );
} {9   9   9   {}   {}   {}}

do_execsql_test 7.3.6 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 1000 PRECEDING AND 2 PRECEDING
  );
} {{}   {}   1   9   9   9}

do_execsql_test 7.3.7 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
  );
} {{}   {}   {}   9   9   9}

do_execsql_test 7.3.8 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 1000 PRECEDING AND 2000 PRECEDING
  );
} {9   9   9   {}   {}   {}}

do_execsql_test 7.3.9 {
  SELECT sum (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
  );
} {9   9   9   {}   {}   {}}

do_execsql_test 7.4.1 {
  SELECT max (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 6 FOLLOWING AND UNBOUNDED FOLLOWING
  );
} {4   4   4   4   4   4}

do_execsql_test 7.4.2 {
  SELECT max (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
  );
} {{}   {}   {}   4   4   4}

do_execsql_test 7.4.3 {
  SELECT max (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
  );
} {{}   {}   {}   4   4   4}

do_execsql_test 7.4.4 {
  SELECT max (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 1 PRECEDING AND 2 PRECEDING
  );
} {4   4   4   {}   {}   {}}

do_execsql_test 7.4.5 {
  SELECT max (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 2 FOLLOWING AND 1 FOLLOWING
  );
} {4   4   4   {}   {}   {}}

do_execsql_test 7.4.6 {
  SELECT max (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 1000 PRECEDING AND 2 PRECEDING
  );
} {{}   {}   1   4   4   4}

do_execsql_test 7.4.7 {
  SELECT max (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS LAST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
  );
} {{}   {}   {}   4   4   4}

do_execsql_test 7.4.8 {
  SELECT max (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 1000 PRECEDING AND 2000 PRECEDING
  );
} {4   4   4   {}   {}   {}}

do_execsql_test 7.4.9 {
  SELECT max (a) OVER win FROM t2
  WINDOW win AS (
      ORDER BY b NULLS FIRST RANGE BETWEEN 2000 FOLLOWING AND 1000 FOLLOWING
  );
} {4   4   4   {}   {}   {}}

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

do_execsql_test 8.0 {
  DROP TABLE IF EXISTS tx;
  CREATE TABLE tx(a INTEGER PRIMARY KEY);
  INSERT INTO tx VALUES(1), (2), (3), (4), (5), (6);

  DROP TABLE IF EXISTS map;
  CREATE TABLE map(v INTEGER PRIMARY KEY, t TEXT);
  INSERT INTO map VALUES
    (1, 'odd'), (2, 'even'), (3, 'odd'), 
    (4, 'even'), (5, 'odd'), (6, 'even');
} {}

do_execsql_test 8.1 {
  SELECT sum(a) OVER (
    PARTITION BY (
      SELECT t FROM map WHERE v=a
    ) ORDER BY a
  ) FROM tx;
} {2   6   12   1   4   9}

do_execsql_test 8.2 {
  SELECT sum(a) OVER win FROM tx
  WINDOW win AS (
    PARTITION BY (
      SELECT t FROM map WHERE v=a
    ) ORDER BY a
  );
} {2   6   12   1   4   9}

do_execsql_test 8.3 {
  WITH map2 AS (
    SELECT * FROM map
  )
  SELECT sum(a) OVER (
    PARTITION BY (
      SELECT t FROM map2 WHERE v=a
    ) ORDER BY a
  ) FROM tx;
} {2   6   12   1   4   9}

do_execsql_test 8.4 {
  WITH map2 AS (
    SELECT * FROM map
  )
  SELECT sum(a) OVER win FROM tx
  WINDOW win AS (
    PARTITION BY (
      SELECT t FROM map2 WHERE v=a
    ) ORDER BY a
  );
} {2   6   12   1   4   9}

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

do_execsql_test 9.1 {
  DROP TABLE IF EXISTS t1;
  DROP TABLE IF EXISTS t2;
  CREATE TABLE t1(a INTEGER);
  CREATE TABLE t2(y INTEGER);
} {}

do_execsql_test 9.2 {
  SELECT (
    SELECT max(a) OVER ( ORDER BY (SELECT sum(a) FROM t1) )
         + min(a) OVER() 
  )
  FROM t1
} {}

finish_test