xref: /sqlite-3.40.0/test/window4.test (revision 553948e5)
16bc5c9e7Sdan# 2018 June 04
26bc5c9e7Sdan#
36bc5c9e7Sdan# The author disclaims copyright to this source code.  In place of
46bc5c9e7Sdan# a legal notice, here is a blessing:
56bc5c9e7Sdan#
66bc5c9e7Sdan#    May you do good and not evil.
76bc5c9e7Sdan#    May you find forgiveness for yourself and forgive others.
86bc5c9e7Sdan#    May you share freely, never taking more than you give.
96bc5c9e7Sdan#
106bc5c9e7Sdan#***********************************************************************
116bc5c9e7Sdan# This file implements regression tests for SQLite library.
126bc5c9e7Sdan#
136bc5c9e7Sdan
146bc5c9e7Sdan####################################################
156bc5c9e7Sdan# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
166bc5c9e7Sdan####################################################
176bc5c9e7Sdan
186bc5c9e7Sdanset testdir [file dirname $argv0]
196bc5c9e7Sdansource $testdir/tester.tcl
206bc5c9e7Sdanset testprefix window4
216bc5c9e7Sdan
2267a9b8edSdanifcapable !windowfunc { finish_test ; return }
236bc5c9e7Sdando_execsql_test 1.0 {
246bc5c9e7Sdan  DROP TABLE IF EXISTS t3;
256bc5c9e7Sdan  CREATE TABLE t3(a TEXT PRIMARY KEY);
266bc5c9e7Sdan  INSERT INTO t3 VALUES('a'), ('b'), ('c'), ('d'), ('e');
276bc5c9e7Sdan  INSERT INTO t3 VALUES('f'), ('g'), ('h'), ('i'), ('j');
286bc5c9e7Sdan} {}
296bc5c9e7Sdan
306bc5c9e7Sdando_execsql_test 1.1 {
316bc5c9e7Sdan  SELECT a, ntile(1) OVER (ORDER BY a) FROM t3
326bc5c9e7Sdan} {a 1   b 1   c 1   d 1   e 1   f 1   g 1   h 1   i 1   j 1}
336bc5c9e7Sdan
346bc5c9e7Sdando_execsql_test 1.2 {
356bc5c9e7Sdan  SELECT a, ntile(2) OVER (ORDER BY a) FROM t3
366bc5c9e7Sdan} {a 1   b 1   c 1   d 1   e 1   f 2   g 2   h 2   i 2   j 2}
376bc5c9e7Sdan
386bc5c9e7Sdando_execsql_test 1.3 {
396bc5c9e7Sdan  SELECT a, ntile(3) OVER (ORDER BY a) FROM t3
406bc5c9e7Sdan} {a 1   b 1   c 1   d 1   e 2   f 2   g 2   h 3   i 3   j 3}
416bc5c9e7Sdan
426bc5c9e7Sdando_execsql_test 1.4 {
436bc5c9e7Sdan  SELECT a, ntile(4) OVER (ORDER BY a) FROM t3
446bc5c9e7Sdan} {a 1   b 1   c 1   d 2   e 2   f 2   g 3   h 3   i 4   j 4}
456bc5c9e7Sdan
466bc5c9e7Sdando_execsql_test 1.5 {
476bc5c9e7Sdan  SELECT a, ntile(5) OVER (ORDER BY a) FROM t3
486bc5c9e7Sdan} {a 1   b 1   c 2   d 2   e 3   f 3   g 4   h 4   i 5   j 5}
496bc5c9e7Sdan
506bc5c9e7Sdando_execsql_test 1.6 {
516bc5c9e7Sdan  SELECT a, ntile(6) OVER (ORDER BY a) FROM t3
526bc5c9e7Sdan} {a 1   b 1   c 2   d 2   e 3   f 3   g 4   h 4   i 5   j 6}
536bc5c9e7Sdan
546bc5c9e7Sdando_execsql_test 1.7 {
556bc5c9e7Sdan  SELECT a, ntile(7) OVER (ORDER BY a) FROM t3
566bc5c9e7Sdan} {a 1   b 1   c 2   d 2   e 3   f 3   g 4   h 5   i 6   j 7}
576bc5c9e7Sdan
586bc5c9e7Sdando_execsql_test 1.8 {
596bc5c9e7Sdan  SELECT a, ntile(8) OVER (ORDER BY a) FROM t3
606bc5c9e7Sdan} {a 1   b 1   c 2   d 2   e 3   f 4   g 5   h 6   i 7   j 8}
616bc5c9e7Sdan
626bc5c9e7Sdando_execsql_test 1.9 {
636bc5c9e7Sdan  SELECT a, ntile(9) OVER (ORDER BY a) FROM t3
646bc5c9e7Sdan} {a 1   b 1   c 2   d 3   e 4   f 5   g 6   h 7   i 8   j 9}
656bc5c9e7Sdan
666bc5c9e7Sdando_execsql_test 1.10 {
676bc5c9e7Sdan  SELECT a, ntile(10) OVER (ORDER BY a) FROM t3
686bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
696bc5c9e7Sdan
706bc5c9e7Sdando_execsql_test 1.11 {
716bc5c9e7Sdan  SELECT a, ntile(11) OVER (ORDER BY a) FROM t3
726bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
736bc5c9e7Sdan
746bc5c9e7Sdando_execsql_test 1.12 {
756bc5c9e7Sdan  SELECT a, ntile(12) OVER (ORDER BY a) FROM t3
766bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
776bc5c9e7Sdan
786bc5c9e7Sdando_execsql_test 1.13 {
796bc5c9e7Sdan  SELECT a, ntile(13) OVER (ORDER BY a) FROM t3
806bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
816bc5c9e7Sdan
826bc5c9e7Sdando_execsql_test 1.14 {
836bc5c9e7Sdan  SELECT a, ntile(14) OVER (ORDER BY a) FROM t3
846bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
856bc5c9e7Sdan
866bc5c9e7Sdando_execsql_test 1.15 {
876bc5c9e7Sdan  SELECT a, ntile(15) OVER (ORDER BY a) FROM t3
886bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
896bc5c9e7Sdan
906bc5c9e7Sdando_execsql_test 1.16 {
916bc5c9e7Sdan  SELECT a, ntile(16) OVER (ORDER BY a) FROM t3
926bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
936bc5c9e7Sdan
946bc5c9e7Sdando_execsql_test 1.17 {
956bc5c9e7Sdan  SELECT a, ntile(17) OVER (ORDER BY a) FROM t3
966bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
976bc5c9e7Sdan
986bc5c9e7Sdando_execsql_test 1.18 {
996bc5c9e7Sdan  SELECT a, ntile(18) OVER (ORDER BY a) FROM t3
1006bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
1016bc5c9e7Sdan
1026bc5c9e7Sdando_execsql_test 1.19 {
1036bc5c9e7Sdan  SELECT a, ntile(19) OVER (ORDER BY a) FROM t3
1046bc5c9e7Sdan} {a 1   b 2   c 3   d 4   e 5   f 6   g 7   h 8   i 9   j 10}
1056bc5c9e7Sdan
106ec891fd4Sdando_execsql_test 2.0 {
107ec891fd4Sdan  DROP TABLE IF EXISTS t4;
108ec891fd4Sdan  CREATE TABLE t4(a INTEGER PRIMARY KEY, b TEXT, c INTEGER);
109ec891fd4Sdan  INSERT INTO t4 VALUES(1, 'A', 9);
110ec891fd4Sdan  INSERT INTO t4 VALUES(2, 'B', 3);
111ec891fd4Sdan  INSERT INTO t4 VALUES(3, 'C', 2);
112ec891fd4Sdan  INSERT INTO t4 VALUES(4, 'D', 10);
113ec891fd4Sdan  INSERT INTO t4 VALUES(5, 'E', 5);
114ec891fd4Sdan  INSERT INTO t4 VALUES(6, 'F', 1);
115ec891fd4Sdan  INSERT INTO t4 VALUES(7, 'G', 1);
116ec891fd4Sdan  INSERT INTO t4 VALUES(8, 'H', 2);
117ec891fd4Sdan  INSERT INTO t4 VALUES(9, 'I', 10);
118ec891fd4Sdan  INSERT INTO t4 VALUES(10, 'J', 4);
119ec891fd4Sdan} {}
120ec891fd4Sdan
121ec891fd4Sdando_execsql_test 2.1 {
122ec891fd4Sdan  SELECT a, nth_value(b, c) OVER (ORDER BY a) FROM t4
123ec891fd4Sdan} {1 {}   2 {}   3 B   4 {}   5 E   6 A   7 A   8 B   9 {}   10 D}
124ec891fd4Sdan
125fe4e25a0Sdando_execsql_test 2.2.1 {
126fe4e25a0Sdan  SELECT a, lead(b) OVER (ORDER BY a) FROM t4
127fe4e25a0Sdan} {1 B   2 C   3 D   4 E   5 F   6 G   7 H   8 I   9 J   10 {}}
128fe4e25a0Sdan
129fe4e25a0Sdando_execsql_test 2.2.2 {
130fe4e25a0Sdan  SELECT a, lead(b, 2) OVER (ORDER BY a) FROM t4
131fe4e25a0Sdan} {1 C   2 D   3 E   4 F   5 G   6 H   7 I   8 J   9 {}   10 {}}
132fe4e25a0Sdan
133fe4e25a0Sdando_execsql_test 2.2.3 {
134fe4e25a0Sdan  SELECT a, lead(b, 3, 'abc') OVER (ORDER BY a) FROM t4
135fe4e25a0Sdan} {1 D   2 E   3 F   4 G   5 H   6 I   7 J   8 abc   9 abc   10 abc}
136fe4e25a0Sdan
137fe4e25a0Sdando_execsql_test 2.3.1 {
138fe4e25a0Sdan  SELECT a, lag(b) OVER (ORDER BY a) FROM t4
139fe4e25a0Sdan} {1 {}   2 A   3 B   4 C   5 D   6 E   7 F   8 G   9 H   10 I}
140fe4e25a0Sdan
141fe4e25a0Sdando_execsql_test 2.3.2 {
142fe4e25a0Sdan  SELECT a, lag(b, 2) OVER (ORDER BY a) FROM t4
143fe4e25a0Sdan} {1 {}   2 {}   3 A   4 B   5 C   6 D   7 E   8 F   9 G   10 H}
144fe4e25a0Sdan
145fe4e25a0Sdando_execsql_test 2.3.3 {
146fe4e25a0Sdan  SELECT a, lag(b, 3, 'abc') OVER (ORDER BY a) FROM t4
147fe4e25a0Sdan} {1 abc   2 abc   3 abc   4 A   5 B   6 C   7 D   8 E   9 F   10 G}
148fe4e25a0Sdan
14903854d2eSdando_execsql_test 2.4.1 {
15003854d2eSdan  SELECT group_concat(b, '.') OVER (
15103854d2eSdan    ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
15203854d2eSdan  ) FROM t4
153108e6b2cSdan} {A.B.C.D.E.F.G.H.I.J   B.C.D.E.F.G.H.I.J   C.D.E.F.G.H.I.J   D.E.F.G.H.I.J
154108e6b2cSdan  E.F.G.H.I.J   F.G.H.I.J   G.H.I.J   H.I.J   I.J   J}
15503854d2eSdan
156ec891fd4Sdando_execsql_test 3.0 {
157ec891fd4Sdan  DROP TABLE IF EXISTS t5;
158ec891fd4Sdan  CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
159ec891fd4Sdan  INSERT INTO t5 VALUES(1, 'A', 'one',   5);
160ec891fd4Sdan  INSERT INTO t5 VALUES(2, 'B', 'two',   4);
161ec891fd4Sdan  INSERT INTO t5 VALUES(3, 'A', 'three', 3);
162ec891fd4Sdan  INSERT INTO t5 VALUES(4, 'B', 'four',  2);
163ec891fd4Sdan  INSERT INTO t5 VALUES(5, 'A', 'five',  1);
164ec891fd4Sdan} {}
165ec891fd4Sdan
166ec891fd4Sdando_execsql_test 3.1 {
167ec891fd4Sdan  SELECT a, nth_value(c, d) OVER (ORDER BY b) FROM t5
168ec891fd4Sdan} {1 {}   3 five   5 one   2 two   4 three}
169ec891fd4Sdan
170ec891fd4Sdando_execsql_test 3.2 {
171ec891fd4Sdan  SELECT a, nth_value(c, d) OVER (PARTITION BY b ORDER BY a) FROM t5
172ec891fd4Sdan} {1 {}   3 {}   5 one   2 {}   4 four}
173ec891fd4Sdan
174e3bf632cSdando_execsql_test 3.3 {
175e3bf632cSdan  SELECT a, count(*) OVER abc, count(*) OVER def FROM t5
176e3bf632cSdan  WINDOW abc AS (ORDER BY a),
177e3bf632cSdan         def AS (ORDER BY a DESC)
178e3bf632cSdan  ORDER BY a;
179e3bf632cSdan} {1 1 5   2 2 4   3 3 3   4 4 2   5 5 1}
180e3bf632cSdan
1818b98560dSdando_execsql_test 3.4 {
1828b98560dSdan  SELECT a, max(a) FILTER (WHERE (a%2)=0) OVER w FROM t5
1838b98560dSdan  WINDOW w AS (ORDER BY a)
1848b98560dSdan} {1 {}   2 2   3 2   4 4   5 4}
1858b98560dSdan
18626522d1cSdando_execsql_test 3.5.1 {
18726522d1cSdan  SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING)
18826522d1cSdan  FROM t5
18926522d1cSdan} {1 {}   2 {}   3 {}   4 {}   5 {}}
19026522d1cSdan
19126522d1cSdando_execsql_test 3.5.2 {
19226522d1cSdan  SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
19326522d1cSdan  FROM t5
19426522d1cSdan} {1 {}   2 one   3 two   4 three   5 four}
19526522d1cSdan
19626522d1cSdando_execsql_test 3.5.3 {
19726522d1cSdan  SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 PRECEDING AND 0 PRECEDING)
19826522d1cSdan  FROM t5
19926522d1cSdan} {1 one   2 two   3 three   4 four   5 five}
20026522d1cSdan
20126522d1cSdando_execsql_test 3.6.1 {
20226522d1cSdan  SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 1 FOLLOWING)
20326522d1cSdan  FROM t5
20426522d1cSdan} {1 {}   2 {}   3 {}   4 {}   5 {}}
20526522d1cSdan
20626522d1cSdando_execsql_test 3.6.2 {
20726522d1cSdan  SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)
20826522d1cSdan  FROM t5
20926522d1cSdan} {1 two   2 three   3 four   4 five   5 {}}
21026522d1cSdan
21126522d1cSdando_execsql_test 3.6.3 {
21226522d1cSdan  SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 FOLLOWING AND 0 FOLLOWING)
21326522d1cSdan  FROM t5
21426522d1cSdan} {1 one   2 two   3 three   4 four   5 five}
21526522d1cSdan
2169a94722dSdan#==========================================================================
2179a94722dSdan
2187392569fSdando_execsql_test 4.0 {
2197392569fSdan  DROP TABLE IF EXISTS ttt;
2207392569fSdan  CREATE TABLE ttt(a INTEGER PRIMARY KEY, b INTEGER, c INTEGER);
2217392569fSdan  INSERT INTO ttt VALUES(1, 1, 1);
2227392569fSdan  INSERT INTO ttt VALUES(2, 2, 2);
2237392569fSdan  INSERT INTO ttt VALUES(3, 3, 3);
2247392569fSdan
2257392569fSdan  INSERT INTO ttt VALUES(4, 1, 2);
2267392569fSdan  INSERT INTO ttt VALUES(5, 2, 3);
2277392569fSdan  INSERT INTO ttt VALUES(6, 3, 4);
2287392569fSdan
2297392569fSdan  INSERT INTO ttt VALUES(7, 1, 3);
2307392569fSdan  INSERT INTO ttt VALUES(8, 2, 4);
2317392569fSdan  INSERT INTO ttt VALUES(9, 3, 5);
2327392569fSdan} {}
2337392569fSdan
2347392569fSdando_execsql_test 4.1 {
2357392569fSdan  SELECT max(c), max(b) OVER (ORDER BY b) FROM ttt GROUP BY b;
2367392569fSdan} {3 1   4 2   5 3}
2377392569fSdan
238c0bb4459Sdando_execsql_test 4.2 {
239c0bb4459Sdan  SELECT max(b) OVER (ORDER BY max(c)) FROM ttt GROUP BY b;
240c0bb4459Sdan} {1   2   3}
241c0bb4459Sdan
242c0bb4459Sdando_execsql_test 4.3 {
243c0bb4459Sdan  SELECT abs(max(b) OVER (ORDER BY b)) FROM ttt GROUP BY b;
244c0bb4459Sdan} {1   2   3}
245c0bb4459Sdan
24613078caaSdando_execsql_test 4.4 {
24713078caaSdan  SELECT sum(b) OVER (
24813078caaSdan    ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
24913078caaSdan  ) FROM ttt;
25013078caaSdan} {18   17   15   12   11   9   6   5   3}
25113078caaSdan
2529a94722dSdando_execsql_test 4.5.1.1 {
2539a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
2549a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
2559a94722dSdan  FROM ttt ORDER BY a
2569a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
2579a94722dSdan
258303451a8Sdando_execsql_test 4.5.1.2 {
259303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
260303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
261303451a8Sdan  FROM ttt ORDER BY a
262303451a8Sdan} {1 1   2 2   3 3   3 3   5 5   7 7   6 6   9 9   12 12}
2639a94722dSdan
2649a94722dSdando_execsql_test 4.5.2.1 {
2659a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
2669a94722dSdan  min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
2679a94722dSdan  FROM ttt ORDER BY a
2689a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
2699a94722dSdan
270303451a8Sdando_execsql_test 4.5.2.2 {
271303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
272303451a8Sdan         sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
273303451a8Sdan  FROM ttt ORDER BY a
274303451a8Sdan} {1 1   2 2   3 3   3 2   5 3   7 4   6 3   9 4   12 5}
2759a94722dSdan
2769a94722dSdando_execsql_test 4.5.3.1 {
2779a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
2789a94722dSdan  min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
2799a94722dSdan  FROM ttt ORDER BY a
2809a94722dSdan} {1 1   2 1   3 1   2 1   3 1   4 1   3 1   4 1   5 1}
2819a94722dSdan
282303451a8Sdando_execsql_test 4.5.3.2 {
283303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
284303451a8Sdan         sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
285303451a8Sdan  FROM ttt ORDER BY a
286303451a8Sdan} {1 1   2 3   3 6   3 8   5 11   7 15   6 18   9 22   12 27}
2879a94722dSdan
2889a94722dSdando_execsql_test 4.5.4.1 {
2899a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
2909a94722dSdan  min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
2919a94722dSdan  FROM ttt ORDER BY a
2929a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
2939a94722dSdan
294303451a8Sdando_execsql_test 4.5.4.2 {
295303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
296303451a8Sdan         sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
297303451a8Sdan  FROM ttt ORDER BY a
298303451a8Sdan} {1 1   2 2   3 3   3 2   5 3   7 4   6 3   9 4   12 5}
2999a94722dSdan
3009a94722dSdando_execsql_test 4.5.5.1 {
3019a94722dSdan  SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
3029a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
3039a94722dSdan  FROM ttt ORDER BY a
3049a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
3059a94722dSdan
306303451a8Sdando_execsql_test 4.5.5.2 {
307303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
308303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
309303451a8Sdan  FROM ttt ORDER BY a
310303451a8Sdan} {1 1   2 2   3 3   2 3   3 5   4 7   3 6   4 9   5 12}
3119a94722dSdan
3129a94722dSdando_execsql_test 4.5.6.1 {
3139a94722dSdan  SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
3149a94722dSdan  min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
3159a94722dSdan  FROM ttt ORDER BY a
3169a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
3179a94722dSdan
318303451a8Sdando_execsql_test 4.5.6.2 {
319303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
320303451a8Sdan         sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
321303451a8Sdan  FROM ttt ORDER BY a
322303451a8Sdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
3239a94722dSdan
3249a94722dSdando_execsql_test 4.5.7.1 {
3259a94722dSdan  SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
3269a94722dSdan  min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
3279a94722dSdan  FROM ttt ORDER BY a
3289a94722dSdan} {1 1   2 1   3 1   2 1   3 1   4 1   3 1   4 1   5 1}
3299a94722dSdan
330303451a8Sdando_execsql_test 4.5.7.2 {
331303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
332303451a8Sdan         sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
333303451a8Sdan  FROM ttt ORDER BY a
334303451a8Sdan} {1 1   2 3   3 6   2 8   3 11   4 15   3 18   4 22   5 27}
3359a94722dSdan
3369a94722dSdando_execsql_test 4.5.8.1 {
3379a94722dSdan  SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
3389a94722dSdan  min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
3399a94722dSdan  FROM ttt ORDER BY a
3409a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
3419a94722dSdan
342303451a8Sdando_execsql_test 4.5.8.2 {
343303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
344303451a8Sdan         sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
345303451a8Sdan  FROM ttt ORDER BY a
346303451a8Sdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
3479a94722dSdan
3489a94722dSdando_execsql_test 4.5.9.1 {
3499a94722dSdan  SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
3509a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
3519a94722dSdan  FROM ttt ORDER BY a
3529a94722dSdan} {1 1   2 2   3 3   3 1   3 2   4 3   4 1   4 2   5 3}
3539a94722dSdan
354303451a8Sdando_execsql_test 4.5.9.2 {
355303451a8Sdan  SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
356303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
357303451a8Sdan  FROM ttt ORDER BY a
358303451a8Sdan} {1 1   3 2   6 3   8 3   11 5   15 7   18 6   22 9   27 12}
3599a94722dSdan
3609a94722dSdando_execsql_test 4.5.10.1 {
3619a94722dSdan  SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
3629a94722dSdan  min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
3639a94722dSdan  FROM ttt ORDER BY a
3649a94722dSdan} {1 1   2 2   3 3   3 2   3 3   4 4   4 3   4 4   5 5}
3659a94722dSdan
366303451a8Sdando_execsql_test 4.5.10.2 {
367303451a8Sdan  SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
368303451a8Sdan         sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
369303451a8Sdan  FROM ttt ORDER BY a
370303451a8Sdan} {1 1   3 2   6 3   8 2   11 3   15 4   18 3   22 4   27 5}
3719a94722dSdan
3729a94722dSdando_execsql_test 4.5.11.1 {
3739a94722dSdan  SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
3749a94722dSdan  min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
3759a94722dSdan  FROM ttt ORDER BY a
3769a94722dSdan} {1 1   2 1   3 1   3 1   3 1   4 1   4 1   4 1   5 1}
3779a94722dSdan
378303451a8Sdando_execsql_test 4.5.11.2 {
379303451a8Sdan  SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
380303451a8Sdan         sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
381303451a8Sdan  FROM ttt ORDER BY a
382303451a8Sdan} {1 1   3 3   6 6   8 8   11 11   15 15   18 18   22 22   27 27}
3839a94722dSdan
3849a94722dSdando_execsql_test 4.5.12.1 {
3859a94722dSdan  SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
3869a94722dSdan  min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
3879a94722dSdan  FROM ttt ORDER BY a
3889a94722dSdan} {1 1   2 2   3 3   3 2   3 3   4 4   4 3   4 4   5 5}
3899a94722dSdan
390303451a8Sdando_execsql_test 4.5.12.2 {
391303451a8Sdan  SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
392303451a8Sdan         sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
393303451a8Sdan  FROM ttt ORDER BY a
394303451a8Sdan} {1 1   3 2   6 3   8 2   11 3   15 4   18 3   22 4   27 5}
3959a94722dSdan
3969a94722dSdando_execsql_test 4.5.13.1 {
3979a94722dSdan  SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
3989a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
3999a94722dSdan  FROM ttt ORDER BY a
4009a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
4019a94722dSdan
402303451a8Sdando_execsql_test 4.5.13.2 {
403303451a8Sdan  SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
404303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
405303451a8Sdan  FROM ttt ORDER BY a
406303451a8Sdan} {1 1   2 2   3 3   2 3   3 5   4 7   3 6   4 9   5 12}
4079a94722dSdan
4089a94722dSdando_execsql_test 4.5.14.1 {
4099a94722dSdan  SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
4109a94722dSdan  min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
4119a94722dSdan  FROM ttt ORDER BY a
4129a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
4139a94722dSdan
414303451a8Sdando_execsql_test 4.5.14.2 {
415303451a8Sdan  SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
416303451a8Sdan         sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
417303451a8Sdan  FROM ttt ORDER BY a
418303451a8Sdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
4199a94722dSdan
4209a94722dSdando_execsql_test 4.5.15.1 {
4219a94722dSdan  SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
4229a94722dSdan  min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
4239a94722dSdan  FROM ttt ORDER BY a
4249a94722dSdan} {1 1   2 1   3 1   2 1   3 1   4 1   3 1   4 1   5 1}
4259a94722dSdan
426303451a8Sdando_execsql_test 4.5.15.2 {
427303451a8Sdan  SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
428303451a8Sdan         sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
429303451a8Sdan  FROM ttt ORDER BY a
430303451a8Sdan} {1 1   2 3   3 6   2 8   3 11   4 15   3 18   4 22   5 27}
4319a94722dSdan
4329a94722dSdando_execsql_test 4.5.16.1 {
4339a94722dSdan  SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
4349a94722dSdan  min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
4359a94722dSdan  FROM ttt ORDER BY a
4369a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
4379a94722dSdan
438303451a8Sdando_execsql_test 4.5.16.2 {
439303451a8Sdan  SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
440303451a8Sdan         sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
441303451a8Sdan  FROM ttt ORDER BY a
442303451a8Sdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
4439a94722dSdan
4449a94722dSdando_execsql_test 4.5.17.1 {
4459a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
4469a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
4479a94722dSdan  FROM ttt ORDER BY a
4489a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
4499a94722dSdan
450303451a8Sdando_execsql_test 4.5.17.2 {
451303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
452303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
453303451a8Sdan  FROM ttt ORDER BY a
454303451a8Sdan} {1 1   2 2   3 3   3 3   5 5   7 7   6 6   9 9   12 12}
4559a94722dSdan
4569a94722dSdando_execsql_test 4.5.18.1 {
4579a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
4589a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
4599a94722dSdan  FROM ttt ORDER BY a
4609a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
4619a94722dSdan
462303451a8Sdando_execsql_test 4.5.18.2 {
463303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
464303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
465303451a8Sdan  FROM ttt ORDER BY a
466303451a8Sdan} {1 6   2 9   3 12   3 6   5 9   7 12   6 6   9 9   12 12}
4679a94722dSdan
4689a94722dSdando_execsql_test 4.5.19.1 {
4699a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
4709a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
4719a94722dSdan  FROM ttt ORDER BY a
4729a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
4739a94722dSdan
474303451a8Sdando_execsql_test 4.5.19.2 {
475303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
476303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
477303451a8Sdan  FROM ttt ORDER BY a
478303451a8Sdan} {1 1   2 2   3 3   3 2   5 3   7 4   6 3   9 4   12 5}
4799a94722dSdan
4809a94722dSdando_execsql_test 4.5.20.1 {
4819a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
4829a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
4839a94722dSdan  FROM ttt ORDER BY a
4849a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
4859a94722dSdan
486303451a8Sdando_execsql_test 4.5.20.2 {
487303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
488303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
489303451a8Sdan  FROM ttt ORDER BY a
490303451a8Sdan} {1 6   2 9   3 12   3 5   5 7   7 9   6 3   9 4   12 5}
4919a94722dSdan
4929a94722dSdando_execsql_test 4.5.21.1 {
4939a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
4949a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
4959a94722dSdan  FROM ttt ORDER BY a
4969a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
4979a94722dSdan
498303451a8Sdando_execsql_test 4.5.21.2 {
499303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
500303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
501303451a8Sdan  FROM ttt ORDER BY a
502303451a8Sdan} {6 1   9 2   12 3   6 3   9 5   12 7   6 6   9 9   12 12}
5039a94722dSdan
5049a94722dSdando_execsql_test 4.5.22.1 {
5059a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
5069a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
5079a94722dSdan  FROM ttt ORDER BY a
5089a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
5099a94722dSdan
510303451a8Sdando_execsql_test 4.5.22.2 {
511303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
512303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
513303451a8Sdan  FROM ttt ORDER BY a
514303451a8Sdan} {6 6   9 9   12 12   6 6   9 9   12 12   6 6   9 9   12 12}
5159a94722dSdan
5169a94722dSdando_execsql_test 4.5.23.1 {
5179a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
5189a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
5199a94722dSdan  FROM ttt ORDER BY a
5209a94722dSdan} {3 1   4 2   5 3   3 2   4 3   5 4   3 3   4 4   5 5}
5219a94722dSdan
522303451a8Sdando_execsql_test 4.5.23.2 {
523303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
524303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
525303451a8Sdan  FROM ttt ORDER BY a
526303451a8Sdan} {6 1   9 2   12 3   6 2   9 3   12 4   6 3   9 4   12 5}
5279a94722dSdan
5289a94722dSdando_execsql_test 4.5.24.1 {
5299a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
5309a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
5319a94722dSdan  FROM ttt ORDER BY a
5329a94722dSdan} {3 1   4 2   5 3   3 2   4 3   5 4   3 3   4 4   5 5}
5339a94722dSdan
534303451a8Sdando_execsql_test 4.5.24.2 {
535303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
536303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
537303451a8Sdan  FROM ttt ORDER BY a
538303451a8Sdan} {6 6   9 9   12 12   6 5   9 7   12 9   6 3   9 4   12 5}
5399a94722dSdan
5409a94722dSdando_execsql_test 4.5.25.1 {
5419a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
5429a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
5439a94722dSdan  FROM ttt ORDER BY a
5449a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
5459a94722dSdan
546303451a8Sdando_execsql_test 4.5.25.2 {
547303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
548303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
549303451a8Sdan  FROM ttt ORDER BY a
550303451a8Sdan} {1 1   2 2   3 3   2 3   3 5   4 7   3 6   4 9   5 12}
5519a94722dSdan
5529a94722dSdando_execsql_test 4.5.26.1 {
5539a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
5549a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
5559a94722dSdan  FROM ttt ORDER BY a
5569a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
5579a94722dSdan
558303451a8Sdando_execsql_test 4.5.26.2 {
559303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
560303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
561303451a8Sdan  FROM ttt ORDER BY a
562303451a8Sdan} {1 6   2 9   3 12   2 6   3 9   4 12   3 6   4 9   5 12}
5639a94722dSdan
5649a94722dSdando_execsql_test 4.5.27.1 {
5659a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
5669a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
5679a94722dSdan  FROM ttt ORDER BY a
5689a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
5699a94722dSdan
570303451a8Sdando_execsql_test 4.5.27.2 {
571303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
572303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
573303451a8Sdan  FROM ttt ORDER BY a
574303451a8Sdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
5759a94722dSdan
5769a94722dSdando_execsql_test 4.5.28.1 {
5779a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
5789a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
5799a94722dSdan  FROM ttt ORDER BY a
5809a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
5819a94722dSdan
582303451a8Sdando_execsql_test 4.5.28.2 {
583303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
584303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
585303451a8Sdan  FROM ttt ORDER BY a
586303451a8Sdan} {1 6   2 9   3 12   2 5   3 7   4 9   3 3   4 4   5 5}
5879a94722dSdan
5889a94722dSdando_execsql_test 4.5.29.1 {
5899a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
5909a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
5919a94722dSdan  FROM ttt ORDER BY a
5929a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
5939a94722dSdan
594303451a8Sdando_execsql_test 4.5.29.2 {
595303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
596303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
597303451a8Sdan  FROM ttt ORDER BY a
598303451a8Sdan} {6 1   9 2   12 3   5 3   7 5   9 7   3 6   4 9   5 12}
5999a94722dSdan
6009a94722dSdando_execsql_test 4.5.30.1 {
6019a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
6029a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
6039a94722dSdan  FROM ttt ORDER BY a
6049a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
6059a94722dSdan
606303451a8Sdando_execsql_test 4.5.30.2 {
607303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
608303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
609303451a8Sdan  FROM ttt ORDER BY a
610303451a8Sdan} {6 6   9 9   12 12   5 6   7 9   9 12   3 6   4 9   5 12}
6119a94722dSdan
6129a94722dSdando_execsql_test 4.5.31.1 {
6139a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
6149a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
6159a94722dSdan  FROM ttt ORDER BY a
6169a94722dSdan} {3 1   4 2   5 3   3 2   4 3   5 4   3 3   4 4   5 5}
6179a94722dSdan
618303451a8Sdando_execsql_test 4.5.31.2 {
619303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
620303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
621303451a8Sdan  FROM ttt ORDER BY a
622303451a8Sdan} {6 1   9 2   12 3   5 2   7 3   9 4   3 3   4 4   5 5}
6239a94722dSdan
6249a94722dSdando_execsql_test 4.5.32.1 {
6259a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
6269a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
6279a94722dSdan  FROM ttt ORDER BY a
6289a94722dSdan} {3 1   4 2   5 3   3 2   4 3   5 4   3 3   4 4   5 5}
6299a94722dSdan
630303451a8Sdando_execsql_test 4.5.32.2 {
631303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
632303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
633303451a8Sdan  FROM ttt ORDER BY a
634303451a8Sdan} {6 6   9 9   12 12   5 5   7 7   9 9   3 3   4 4   5 5}
6359a94722dSdan
6369a94722dSdando_execsql_test 4.5.33.1 {
637303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
638303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
6399a94722dSdan  FROM ttt ORDER BY a
640303451a8Sdan} {2 1   3 2   4 3   3 1   4 2   5 3   3 1   4 2   5 3}
6419a94722dSdan
642303451a8Sdando_execsql_test 4.5.33.2 {
643303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
644303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
645303451a8Sdan  FROM ttt ORDER BY a
646303451a8Sdan} {3 3   5 5   7 7   6 6   9 9   12 12   6 6   9 9   12 12}
6479a94722dSdan
6489a94722dSdando_execsql_test 4.5.34.1 {
649303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
650303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
6519a94722dSdan  FROM ttt ORDER BY a
652303451a8Sdan} {2 1   3 2   4 3   3 1   4 2   5 3   3 1   4 2   5 3}
6539a94722dSdan
654303451a8Sdando_execsql_test 4.5.34.2 {
655303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
656303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
657303451a8Sdan  FROM ttt ORDER BY a
658303451a8Sdan} {3 6   5 9   7 12   6 6   9 9   12 12   6 6   9 9   12 12}
6599a94722dSdan
6609a94722dSdando_execsql_test 4.5.35.1 {
661303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
662303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
6639a94722dSdan  FROM ttt ORDER BY a
664303451a8Sdan} {2 {}   3 {}   4 {}   3 1   4 2   5 3   3 2   4 3   5 4}
6659a94722dSdan
666303451a8Sdando_execsql_test 4.5.35.2 {
667303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
668303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
669303451a8Sdan  FROM ttt ORDER BY a
670303451a8Sdan} {3 {}   5 {}   7 {}   6 1   9 2   12 3   6 2   9 3   12 4}
6719a94722dSdan
6729a94722dSdando_execsql_test 4.5.36.1 {
673303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
674303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
675303451a8Sdan  FROM ttt ORDER BY a
676303451a8Sdan} {2 {}   3 {}   4 {}   3 {}   4 {}   5 {}   3 {}   4 {}   5 {}}
677303451a8Sdan
678303451a8Sdando_execsql_test 4.5.36.2 {
679303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
680303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
681303451a8Sdan  FROM ttt ORDER BY a
682303451a8Sdan} {3 {}   5 {}   7 {}   6 {}   9 {}   12 {}   6 {}   9 {}   12 {}}
683303451a8Sdan
684303451a8Sdando_execsql_test 4.5.37.1 {
685303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
686303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
687303451a8Sdan  FROM ttt ORDER BY a
688303451a8Sdan} {2 2   3 3   4 4   3 3   4 4   5 5   3 {}   4 {}   5 {}}
689303451a8Sdan
690303451a8Sdando_execsql_test 4.5.37.2 {
691303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
692303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
693303451a8Sdan  FROM ttt ORDER BY a
694303451a8Sdan} {3 5   5 7   7 9   6 3   9 4   12 5   6 {}   9 {}   12 {}}
695303451a8Sdan
696303451a8Sdando_execsql_test 4.5.38.1 {
697303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
698303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
699303451a8Sdan  FROM ttt ORDER BY a
700303451a8Sdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
701303451a8Sdan
702303451a8Sdando_execsql_test 4.5.38.2 {
703303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
704303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
705303451a8Sdan  FROM ttt ORDER BY a
706303451a8Sdan} {6 3   9 5   12 7   6 6   9 9   12 12   6 6   9 9   12 12}
707303451a8Sdan
708303451a8Sdando_execsql_test 4.5.39.1 {
709303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
710303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
711303451a8Sdan  FROM ttt ORDER BY a
712303451a8Sdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
713303451a8Sdan
714303451a8Sdando_execsql_test 4.5.39.2 {
715303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
716303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
717303451a8Sdan  FROM ttt ORDER BY a
718303451a8Sdan} {6 6   9 9   12 12   6 6   9 9   12 12   6 6   9 9   12 12}
719303451a8Sdan
720303451a8Sdando_execsql_test 4.5.40.1 {
721303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
722303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
723303451a8Sdan  FROM ttt ORDER BY a
724303451a8Sdan} {3 {}   4 {}   5 {}   3 1   4 2   5 3   3 2   4 3   5 4}
725303451a8Sdan
726303451a8Sdando_execsql_test 4.5.40.2 {
727303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
728303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
729303451a8Sdan  FROM ttt ORDER BY a
730303451a8Sdan} {6 {}   9 {}   12 {}   6 1   9 2   12 3   6 2   9 3   12 4}
731303451a8Sdan
732303451a8Sdando_execsql_test 4.5.41.1 {
733303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
734303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
735303451a8Sdan  FROM ttt ORDER BY a
736303451a8Sdan} {3 {}   4 {}   5 {}   3 {}   4 {}   5 {}   3 {}   4 {}   5 {}}
737303451a8Sdan
738303451a8Sdando_execsql_test 4.5.41.2 {
739303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
740303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
741303451a8Sdan  FROM ttt ORDER BY a
742303451a8Sdan} {6 {}   9 {}   12 {}   6 {}   9 {}   12 {}   6 {}   9 {}   12 {}}
743303451a8Sdan
744303451a8Sdando_execsql_test 4.5.42.1 {
745303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
746303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
747303451a8Sdan  FROM ttt ORDER BY a
748303451a8Sdan} {3 2   4 3   5 4   3 3   4 4   5 5   3 {}   4 {}   5 {}}
749303451a8Sdan
750303451a8Sdando_execsql_test 4.5.42.2 {
751303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
752303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
753303451a8Sdan  FROM ttt ORDER BY a
754303451a8Sdan} {6 5   9 7   12 9   6 3   9 4   12 5   6 {}   9 {}   12 {}}
755303451a8Sdan
756303451a8Sdando_execsql_test 4.5.43.1 {
757303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
758303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
759303451a8Sdan  FROM ttt ORDER BY a
760303451a8Sdan} {{} 1   {} 2   {} 3   1 1   2 2   3 3   2 1   3 2   4 3}
761303451a8Sdan
762303451a8Sdando_execsql_test 4.5.43.2 {
763303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
764303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
765303451a8Sdan  FROM ttt ORDER BY a
766303451a8Sdan} {{} 3   {} 5   {} 7   1 6   2 9   3 12   2 6   3 9   4 12}
767303451a8Sdan
768303451a8Sdando_execsql_test 4.5.44.1 {
769303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
770303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
771303451a8Sdan  FROM ttt ORDER BY a
772303451a8Sdan} {{} 1   {} 2   {} 3   1 1   2 2   3 3   2 1   3 2   4 3}
773303451a8Sdan
774303451a8Sdando_execsql_test 4.5.44.2 {
775303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
776303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
777303451a8Sdan  FROM ttt ORDER BY a
778303451a8Sdan} {{} 6   {} 9   {} 12   1 6   2 9   3 12   2 6   3 9   4 12}
779303451a8Sdan
780303451a8Sdando_execsql_test 4.5.45.1 {
781303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
782303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
783303451a8Sdan  FROM ttt ORDER BY a
784303451a8Sdan} {{} {}   {} {}   {} {}   1 1   2 2   3 3   2 2   3 3   4 4}
785303451a8Sdan
786303451a8Sdando_execsql_test 4.5.45.2 {
787303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
788303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
789303451a8Sdan  FROM ttt ORDER BY a
790303451a8Sdan} {{} {}   {} {}   {} {}   1 1   2 2   3 3   2 2   3 3   4 4}
791303451a8Sdan
792303451a8Sdando_execsql_test 4.5.46.1 {
793303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
794303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
795303451a8Sdan  FROM ttt ORDER BY a
796303451a8Sdan} {{} {}   {} {}   {} {}   1 {}   2 {}   3 {}   2 {}   3 {}   4 {}}
797303451a8Sdan
798303451a8Sdando_execsql_test 4.5.46.2 {
799303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
800303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
801303451a8Sdan  FROM ttt ORDER BY a
802303451a8Sdan} {{} {}   {} {}   {} {}   1 {}   2 {}   3 {}   2 {}   3 {}   4 {}}
803303451a8Sdan
804303451a8Sdando_execsql_test 4.5.47.1 {
805303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
806303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
807303451a8Sdan  FROM ttt ORDER BY a
808303451a8Sdan} {{} 2   {} 3   {} 4   1 3   2 4   3 5   2 {}   3 {}   4 {}}
809303451a8Sdan
810303451a8Sdando_execsql_test 4.5.47.2 {
811303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
812303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
813303451a8Sdan  FROM ttt ORDER BY a
814303451a8Sdan} {{} 5   {} 7   {} 9   1 3   2 4   3 5   2 {}   3 {}   4 {}}
815303451a8Sdan
816303451a8Sdando_execsql_test 4.5.48.1 {
817303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
818303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
819303451a8Sdan  FROM ttt ORDER BY a
820303451a8Sdan} {{} 1   {} 2   {} 3   {} 1   {} 2   {} 3   {} 1   {} 2   {} 3}
821303451a8Sdan
822303451a8Sdando_execsql_test 4.5.48.2 {
823303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
824303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
825303451a8Sdan  FROM ttt ORDER BY a
826303451a8Sdan} {{} 3   {} 5   {} 7   {} 6   {} 9   {} 12   {} 6   {} 9   {} 12}
827303451a8Sdan
828303451a8Sdando_execsql_test 4.5.49.1 {
829303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
830303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
831303451a8Sdan  FROM ttt ORDER BY a
832303451a8Sdan} {{} 1   {} 2   {} 3   {} 1   {} 2   {} 3   {} 1   {} 2   {} 3}
833303451a8Sdan
834303451a8Sdando_execsql_test 4.5.49.2 {
835303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
836303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
837303451a8Sdan  FROM ttt ORDER BY a
838303451a8Sdan} {{} 6   {} 9   {} 12   {} 6   {} 9   {} 12   {} 6   {} 9   {} 12}
839303451a8Sdan
840303451a8Sdando_execsql_test 4.5.50.1 {
841303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
842303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
843303451a8Sdan  FROM ttt ORDER BY a
844303451a8Sdan} {{} {}   {} {}   {} {}   {} 1   {} 2   {} 3   {} 2   {} 3   {} 4}
845303451a8Sdan
846303451a8Sdando_execsql_test 4.5.50.2 {
847303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
848303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
849303451a8Sdan  FROM ttt ORDER BY a
850303451a8Sdan} {{} {}   {} {}   {} {}   {} 1   {} 2   {} 3   {} 2   {} 3   {} 4}
851303451a8Sdan
852303451a8Sdando_execsql_test 4.5.51.1 {
853303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
854303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
855303451a8Sdan  FROM ttt ORDER BY a
856303451a8Sdan} {{} {}   {} {}   {} {}   {} {}   {} {}   {} {}   {} {}   {} {}   {} {}}
857303451a8Sdan
858303451a8Sdando_execsql_test 4.5.51.2 {
859303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
860303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
861303451a8Sdan  FROM ttt ORDER BY a
862303451a8Sdan} {{} {}   {} {}   {} {}   {} {}   {} {}   {} {}   {} {}   {} {}   {} {}}
863303451a8Sdan
864303451a8Sdando_execsql_test 4.5.52.1 {
865303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
866303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
867303451a8Sdan  FROM ttt ORDER BY a
868303451a8Sdan} {{} 2   {} 3   {} 4   {} 3   {} 4   {} 5   {} {}   {} {}   {} {}}
869303451a8Sdan
870303451a8Sdando_execsql_test 4.5.52.2 {
871303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
872303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
873303451a8Sdan  FROM ttt ORDER BY a
874303451a8Sdan} {{} 5   {} 7   {} 9   {} 3   {} 4   {} 5   {} {}   {} {}   {} {}}
875303451a8Sdan
876303451a8Sdando_execsql_test 4.5.53.1 {
877303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
878303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
879303451a8Sdan  FROM ttt ORDER BY a
880303451a8Sdan} {3 1   4 2   5 3   3 1   4 2   5 3   {} 1   {} 2   {} 3}
881303451a8Sdan
882303451a8Sdando_execsql_test 4.5.53.2 {
883303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
884303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
885303451a8Sdan  FROM ttt ORDER BY a
886303451a8Sdan} {5 3   7 5   9 7   3 6   4 9   5 12   {} 6   {} 9   {} 12}
887303451a8Sdan
888303451a8Sdando_execsql_test 4.5.54.1 {
889303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
890303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
891303451a8Sdan  FROM ttt ORDER BY a
892303451a8Sdan} {3 1   4 2   5 3   3 1   4 2   5 3   {} 1   {} 2   {} 3}
893303451a8Sdan
894303451a8Sdando_execsql_test 4.5.54.2 {
895303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
896303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
897303451a8Sdan  FROM ttt ORDER BY a
898303451a8Sdan} {5 6   7 9   9 12   3 6   4 9   5 12   {} 6   {} 9   {} 12}
899303451a8Sdan
900303451a8Sdando_execsql_test 4.5.55.1 {
901303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
902303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
903303451a8Sdan  FROM ttt ORDER BY a
904303451a8Sdan} {3 {}   4 {}   5 {}   3 1   4 2   5 3   {} 2   {} 3   {} 4}
905303451a8Sdan
906303451a8Sdando_execsql_test 4.5.55.2 {
907303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
908303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
909303451a8Sdan  FROM ttt ORDER BY a
910303451a8Sdan} {5 {}   7 {}   9 {}   3 1   4 2   5 3   {} 2   {} 3   {} 4}
911303451a8Sdan
912303451a8Sdando_execsql_test 4.5.56.1 {
913303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
914303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
915303451a8Sdan  FROM ttt ORDER BY a
916303451a8Sdan} {3 {}   4 {}   5 {}   3 {}   4 {}   5 {}   {} {}   {} {}   {} {}}
917303451a8Sdan
918303451a8Sdando_execsql_test 4.5.56.2 {
919303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
920303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
921303451a8Sdan  FROM ttt ORDER BY a
922303451a8Sdan} {5 {}   7 {}   9 {}   3 {}   4 {}   5 {}   {} {}   {} {}   {} {}}
923303451a8Sdan
924303451a8Sdando_execsql_test 4.5.57.1 {
925303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
926303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
927303451a8Sdan  FROM ttt ORDER BY a
928303451a8Sdan} {3 2   4 3   5 4   3 3   4 4   5 5   {} {}   {} {}   {} {}}
929303451a8Sdan
930303451a8Sdando_execsql_test 4.5.57.2 {
931303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
932303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
933303451a8Sdan  FROM ttt ORDER BY a
934303451a8Sdan} {5 5   7 7   9 9   3 3   4 4   5 5   {} {}   {} {}   {} {}}
935303451a8Sdan
936303451a8Sdando_execsql_test 4.5.58.1 {
937303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
938303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
939303451a8Sdan  FROM ttt ORDER BY a
940303451a8Sdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
941303451a8Sdan
942303451a8Sdando_execsql_test 4.5.58.2 {
943303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
944303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
945303451a8Sdan  FROM ttt ORDER BY a
946303451a8Sdan} {1 1   2 2   3 3   3 3   5 5   7 7   6 6   9 9   12 12}
947303451a8Sdan
948303451a8Sdando_execsql_test 4.5.59.1 {
949303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
950303451a8Sdan  min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
951303451a8Sdan  FROM ttt ORDER BY a
952303451a8Sdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
953303451a8Sdan
954303451a8Sdando_execsql_test 4.5.59.2 {
955303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
956303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
957303451a8Sdan  FROM ttt ORDER BY a
958303451a8Sdan} {1 6   2 9   3 12   3 5   5 7   7 9   6 3   9 4   12 5}
959303451a8Sdan
960303451a8Sdando_execsql_test 4.5.60.1 {
961303451a8Sdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
962303451a8Sdan  min(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
963303451a8Sdan  FROM ttt ORDER BY a
964303451a8Sdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
965303451a8Sdan
966303451a8Sdando_execsql_test 4.5.60.2 {
967303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
968303451a8Sdan         sum(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
969303451a8Sdan  FROM ttt ORDER BY a
970303451a8Sdan} {1 6   2 9   3 12   3 6   5 9   7 12   6 6   9 9   12 12}
971303451a8Sdan
972303451a8Sdando_execsql_test 4.5.61.1 {
9739a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
9749a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
9759a94722dSdan  FROM ttt ORDER BY a
9769a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
9779a94722dSdan
978303451a8Sdando_execsql_test 4.5.61.2 {
979303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
980303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
981303451a8Sdan  FROM ttt ORDER BY a
982303451a8Sdan} {1 1   2 2   3 3   3 3   5 5   7 7   6 6   9 9   12 12}
9839a94722dSdan
984303451a8Sdando_execsql_test 4.5.62.1 {
9859a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
9869a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
9879a94722dSdan  FROM ttt ORDER BY a
9889a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
9899a94722dSdan
990303451a8Sdando_execsql_test 4.5.62.2 {
991303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
992303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
993303451a8Sdan  FROM ttt ORDER BY a
994303451a8Sdan} {6 1   9 2   12 3   5 3   7 5   9 7   3 6   4 9   5 12}
9959a94722dSdan
996303451a8Sdando_execsql_test 4.5.63.1 {
9979a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
9989a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
9999a94722dSdan  FROM ttt ORDER BY a
10009a94722dSdan} {3 1   4 2   5 3   3 2   4 3   5 4   3 3   4 4   5 5}
10019a94722dSdan
1002303451a8Sdando_execsql_test 4.5.63.2 {
1003303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1004303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1005303451a8Sdan  FROM ttt ORDER BY a
1006303451a8Sdan} {6 6   9 9   12 12   5 5   7 7   9 9   3 3   4 4   5 5}
10079a94722dSdan
1008303451a8Sdando_execsql_test 4.5.64.1 {
10099a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
10109a94722dSdan  min(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
10119a94722dSdan  FROM ttt ORDER BY a
10129a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
10139a94722dSdan
1014303451a8Sdando_execsql_test 4.5.64.2 {
1015303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1016303451a8Sdan         sum(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1017303451a8Sdan  FROM ttt ORDER BY a
1018303451a8Sdan} {6 6   9 9   12 12   5 6   7 9   9 12   3 6   4 9   5 12}
10199a94722dSdan
1020303451a8Sdando_execsql_test 4.5.65.1 {
10219a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
10229a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
10239a94722dSdan  FROM ttt ORDER BY a
10249a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
10259a94722dSdan
1026303451a8Sdando_execsql_test 4.5.65.2 {
1027303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1028303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1029303451a8Sdan  FROM ttt ORDER BY a
1030303451a8Sdan} {6 1   9 2   12 3   5 3   7 5   9 7   3 6   4 9   5 12}
10319a94722dSdan
1032303451a8Sdando_execsql_test 4.5.66.1 {
10339a94722dSdan  SELECT max(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
10349a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
10359a94722dSdan  FROM ttt ORDER BY a
10369a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
10379a94722dSdan
1038303451a8Sdando_execsql_test 4.5.66.2 {
1039303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1040303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1041303451a8Sdan  FROM ttt ORDER BY a
1042303451a8Sdan} {6 1   9 2   12 3   6 3   9 5   12 7   6 6   9 9   12 12}
10439a94722dSdan
1044303451a8Sdando_execsql_test 4.5.67.1 {
10459a94722dSdan  SELECT max(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
10469a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
10479a94722dSdan  FROM ttt ORDER BY a
10489a94722dSdan} {3 1   4 2   5 3   3 2   4 3   5 4   3 3   4 4   5 5}
10499a94722dSdan
1050303451a8Sdando_execsql_test 4.5.67.2 {
1051303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1052303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1053303451a8Sdan  FROM ttt ORDER BY a
1054303451a8Sdan} {6 6   9 9   12 12   6 5   9 7   12 9   6 3   9 4   12 5}
10559a94722dSdan
1056303451a8Sdando_execsql_test 4.5.68.1 {
10579a94722dSdan  SELECT max(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
10589a94722dSdan  min(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
10599a94722dSdan  FROM ttt ORDER BY a
10609a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
10619a94722dSdan
1062303451a8Sdando_execsql_test 4.5.68.2 {
1063303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1064303451a8Sdan         sum(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1065303451a8Sdan  FROM ttt ORDER BY a
1066303451a8Sdan} {6 6   9 9   12 12   6 6   9 9   12 12   6 6   9 9   12 12}
10679a94722dSdan
1068303451a8Sdando_execsql_test 4.5.69.1 {
10699a94722dSdan  SELECT max(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
10709a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
10719a94722dSdan  FROM ttt ORDER BY a
10729a94722dSdan} {3 1   4 2   5 3   3 1   4 2   5 3   3 1   4 2   5 3}
10739a94722dSdan
1074303451a8Sdando_execsql_test 4.5.69.2 {
1075303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1076303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1077303451a8Sdan  FROM ttt ORDER BY a
1078303451a8Sdan} {6 1   9 2   12 3   6 3   9 5   12 7   6 6   9 9   12 12}
10799a94722dSdan
1080303451a8Sdando_execsql_test 4.5.70.1 {
10819a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
10829a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
10839a94722dSdan  FROM ttt ORDER BY a
10849a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
10859a94722dSdan
1086303451a8Sdando_execsql_test 4.5.70.2 {
1087303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1088303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1089303451a8Sdan  FROM ttt ORDER BY a
1090303451a8Sdan} {1 1   2 2   3 3   3 3   5 5   7 7   6 6   9 9   12 12}
10919a94722dSdan
1092303451a8Sdando_execsql_test 4.5.71.1 {
10939a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
10949a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
10959a94722dSdan  FROM ttt ORDER BY a
10969a94722dSdan} {1 1   2 2   3 3   2 2   3 3   4 4   3 3   4 4   5 5}
10979a94722dSdan
1098303451a8Sdando_execsql_test 4.5.71.2 {
1099303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1100303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1101303451a8Sdan  FROM ttt ORDER BY a
1102303451a8Sdan} {1 6   2 9   3 12   3 5   5 7   7 9   6 3   9 4   12 5}
11039a94722dSdan
1104303451a8Sdando_execsql_test 4.5.72.1 {
11059a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
11069a94722dSdan  min(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
11079a94722dSdan  FROM ttt ORDER BY a
11089a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
11099a94722dSdan
1110303451a8Sdando_execsql_test 4.5.72.2 {
1111303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1112303451a8Sdan         sum(c) OVER (PARTITION BY b  RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1113303451a8Sdan  FROM ttt ORDER BY a
1114303451a8Sdan} {1 6   2 9   3 12   3 6   5 9   7 12   6 6   9 9   12 12}
11159a94722dSdan
1116303451a8Sdando_execsql_test 4.5.73.1 {
11179a94722dSdan  SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
11189a94722dSdan  min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
11199a94722dSdan  FROM ttt ORDER BY a
11209a94722dSdan} {1 1   2 2   3 3   2 1   3 2   4 3   3 1   4 2   5 3}
11219a94722dSdan
1122303451a8Sdando_execsql_test 4.5.73.2 {
1123303451a8Sdan  SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1124303451a8Sdan         sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1125303451a8Sdan  FROM ttt ORDER BY a
1126303451a8Sdan} {1 1   2 2   3 3   3 3   5 5   7 7   6 6   9 9   12 12}
11279a94722dSdan
1128e0a5e20fSdan#==========================================================================
1129e0a5e20fSdan
1130e0a5e20fSdando_execsql_test 7.0 {
1131e0a5e20fSdan  DROP TABLE IF EXISTS t1;
1132e0a5e20fSdan  CREATE TABLE t1(x INTEGER, y INTEGER);
1133e0a5e20fSdan  INSERT INTO t1 VALUES(1, 2);
1134e0a5e20fSdan  INSERT INTO t1 VALUES(3, 4);
1135e0a5e20fSdan  INSERT INTO t1 VALUES(5, 6);
1136e0a5e20fSdan  INSERT INTO t1 VALUES(7, 8);
1137e0a5e20fSdan  INSERT INTO t1 VALUES(9, 10);
1138e0a5e20fSdan} {}
1139e0a5e20fSdan
1140e0a5e20fSdando_execsql_test 7.1 {
1141e0a5e20fSdan  SELECT lead(y) OVER win FROM t1
1142e0a5e20fSdan  WINDOW win AS (ORDER BY x)
1143e0a5e20fSdan} {4   6   8   10   {}}
1144e0a5e20fSdan
1145e0a5e20fSdando_execsql_test 7.2 {
1146e0a5e20fSdan  SELECT lead(y, 2) OVER win FROM t1
1147e0a5e20fSdan  WINDOW win AS (ORDER BY x)
1148e0a5e20fSdan} {6   8   10   {}   {}}
1149e0a5e20fSdan
1150e0a5e20fSdando_execsql_test 7.3 {
1151e0a5e20fSdan  SELECT lead(y, 3, -1) OVER win FROM t1
1152e0a5e20fSdan  WINDOW win AS (ORDER BY x)
1153e0a5e20fSdan} {8   10   -1   -1   -1}
1154e0a5e20fSdan
1155e0a5e20fSdando_execsql_test 7.4 {
1156e0a5e20fSdan  SELECT
1157e0a5e20fSdan    lead(y) OVER win, lead(y) OVER win
1158e0a5e20fSdan  FROM t1
1159e0a5e20fSdan  WINDOW win AS (ORDER BY x)
1160e0a5e20fSdan} {4 4   6 6   8 8   10 10   {} {}}
1161e0a5e20fSdan
1162e0a5e20fSdando_execsql_test 7.5 {
1163e0a5e20fSdan  SELECT
1164e0a5e20fSdan    lead(y) OVER win,
1165e0a5e20fSdan    lead(y, 2) OVER win,
1166e0a5e20fSdan    lead(y, 3, -1) OVER win
1167e0a5e20fSdan  FROM t1
1168e0a5e20fSdan  WINDOW win AS (ORDER BY x)
1169e0a5e20fSdan} {4 6 8   6 8 10   8 10 -1   10 {} -1   {} {} -1}
1170e0a5e20fSdan
11716fde1799Sdan#==========================================================================
11726fde1799Sdan
11736fde1799Sdando_execsql_test 8.0 {
11746fde1799Sdan  DROP TABLE IF EXISTS t1;
11756fde1799Sdan  CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER, d INTEGER);
11766fde1799Sdan  INSERT INTO t1 VALUES(1, 2, 3, 4);
11776fde1799Sdan  INSERT INTO t1 VALUES(5, 6, 7, 8);
11786fde1799Sdan  INSERT INTO t1 VALUES(9, 10, 11, 12);
11796fde1799Sdan} {}
11806fde1799Sdan
11816fde1799Sdando_execsql_test 8.1 {
11826fde1799Sdan  SELECT row_number() OVER win,
11836fde1799Sdan         nth_value(d,2) OVER win,
11846fde1799Sdan         lead(d) OVER win
11856fde1799Sdan  FROM t1
11866fde1799Sdan  WINDOW win AS (ORDER BY a)
11876fde1799Sdan} {1 {} 8   2 8 12   3 8 {}}
11886fde1799Sdan
11896fde1799Sdando_execsql_test 8.2 {
11906fde1799Sdan  SELECT row_number() OVER win,
11916fde1799Sdan           rank() OVER win,
11926fde1799Sdan           dense_rank() OVER win,
11936fde1799Sdan           ntile(2) OVER win,
11946fde1799Sdan           first_value(d) OVER win,
11956fde1799Sdan           last_value(d) OVER win,
11966fde1799Sdan           nth_value(d,2) OVER win,
11976fde1799Sdan           lead(d) OVER win,
11986fde1799Sdan           lag(d) OVER win,
11996fde1799Sdan           max(d) OVER win,
12006fde1799Sdan           min(d) OVER win
12016fde1799Sdan    FROM t1
12026fde1799Sdan    WINDOW win AS (ORDER BY a)
12036fde1799Sdan} {1 1 1 1 4 4 {} 8 {} 4 4   2 2 2 1 4 8 8 12 4 8 4   3 3 3 2 4 12 8 {} 8 12 4}
12046fde1799Sdan
1205b7306f6fSdan#==========================================================================
1206b7306f6fSdan
1207b7306f6fSdando_execsql_test 9.0 {
1208b7306f6fSdan  DROP TABLE IF EXISTS t2;
1209b7306f6fSdan  CREATE TABLE t2(x INTEGER);
1210b7306f6fSdan  INSERT INTO t2 VALUES(1), (1), (1), (4), (4), (6), (7);
1211b7306f6fSdan} {}
1212b7306f6fSdan
1213b7306f6fSdando_execsql_test 9.1 {
1214b7306f6fSdan  SELECT rank() OVER () FROM t2
1215b7306f6fSdan} {1   1   1   1   1   1   1}
1216b7306f6fSdan
1217b7306f6fSdando_execsql_test 9.2 {
1218b7306f6fSdan  SELECT dense_rank() OVER (PARTITION BY x) FROM t2
1219b7306f6fSdan} {1   1   1   1   1   1   1}
1220b7306f6fSdan
12212fae1504Sdan
1222b7306f6fSdando_test 9.3 {
1223b7306f6fSdan  set myres {}
1224b7306f6fSdan  foreach r [db eval {SELECT x, percent_rank() OVER (PARTITION BY x ORDER BY x) FROM t2}] {
12252fae1504Sdan    lappend myres [format %.4f [set r]]
1226b7306f6fSdan  }
12272fae1504Sdan  set res2 {1.0000 0.0000 1.0000 0.0000 1.0000 0.0000 4.0000 0.0000 4.0000 0.0000 6.0000 0.0000 7.0000 0.0000}
12286c75b396Sdan  set i 0
12292fae1504Sdan  foreach r [set myres] r2 [set res2] {
12302fae1504Sdan    if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
12312fae1504Sdan      error "list element [set i] does not match: got=[set r] expected=[set r2]"
12322fae1504Sdan    }
12336c75b396Sdan    incr i
12342fae1504Sdan  }
12352fae1504Sdan  set {} {}
12362fae1504Sdan} {}
1237b7306f6fSdan
1238867be212Sdando_execsql_test 9.4 {
1239867be212Sdan  SELECT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
1240867be212Sdan} {1 1   1 1   1 1   4 4   4 4   6 6   7 7}
1241867be212Sdan
1242867be212Sdando_execsql_test 9.5 {
1243867be212Sdan  SELECT DISTINCT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
1244867be212Sdan} {1 1   4 4   6 6   7 7}
1245867be212Sdan
12462fae1504Sdan
1247cf0343b6Sdando_test 9.6 {
1248cf0343b6Sdan  set myres {}
1249cf0343b6Sdan  foreach r [db eval {SELECT percent_rank() OVER () FROM t1}] {
12502fae1504Sdan    lappend myres [format %.4f [set r]]
1251cf0343b6Sdan  }
12522fae1504Sdan  set res2 {0.0000 0.0000 0.0000}
12536c75b396Sdan  set i 0
12542fae1504Sdan  foreach r [set myres] r2 [set res2] {
12552fae1504Sdan    if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
12562fae1504Sdan      error "list element [set i] does not match: got=[set r] expected=[set r2]"
12572fae1504Sdan    }
12586c75b396Sdan    incr i
12592fae1504Sdan  }
12602fae1504Sdan  set {} {}
12612fae1504Sdan} {}
12622fae1504Sdan
1263cf0343b6Sdan
1264cf0343b6Sdando_test 9.7 {
1265cf0343b6Sdan  set myres {}
1266cf0343b6Sdan  foreach r [db eval {SELECT cume_dist() OVER () FROM t1}] {
12672fae1504Sdan    lappend myres [format %.4f [set r]]
1268cf0343b6Sdan  }
12692fae1504Sdan  set res2 {1.0000 1.0000 1.0000}
12706c75b396Sdan  set i 0
12712fae1504Sdan  foreach r [set myres] r2 [set res2] {
12722fae1504Sdan    if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
12732fae1504Sdan      error "list element [set i] does not match: got=[set r] expected=[set r2]"
12742fae1504Sdan    }
12756c75b396Sdan    incr i
12762fae1504Sdan  }
12772fae1504Sdan  set {} {}
12782fae1504Sdan} {}
1279cf0343b6Sdan
1280d4fc49f7Sdando_execsql_test 10.0 {
1281d4fc49f7Sdan  DROP TABLE IF EXISTS t7;
1282d4fc49f7Sdan  CREATE TABLE t7(id INTEGER PRIMARY KEY, a INTEGER, b INTEGER);
1283d4fc49f7Sdan  INSERT INTO t7(id, a, b) VALUES
1284d4fc49f7Sdan    (1, 1, 2), (2, 1, NULL), (3, 1, 4),
1285d4fc49f7Sdan    (4, 3, NULL), (5, 3, 8), (6, 3, 1);
1286d4fc49f7Sdan} {}
1287d4fc49f7Sdan
1288d4fc49f7Sdando_execsql_test 10.1 {
1289d4fc49f7Sdan  SELECT id, min(b) OVER (PARTITION BY a ORDER BY id) FROM t7;
1290d4fc49f7Sdan} {1 2   2 2   3 2   4 {}   5 8   6 1}
1291d4fc49f7Sdan
1292a1a7e112Sdando_execsql_test 10.2 {
1293a1a7e112Sdan  SELECT id, lead(b, -1) OVER (PARTITION BY a ORDER BY id) FROM t7;
1294a1a7e112Sdan} {1 {}   2 2   3 {}   4 {}   5 {}   6 8}
1295a1a7e112Sdan
1296a1a7e112Sdando_execsql_test 10.3 {
1297a1a7e112Sdan  SELECT id, lag(b, -1) OVER (PARTITION BY a ORDER BY id) FROM t7;
1298a1a7e112Sdan} {1 {}   2 4   3 {}   4 8   5 1   6 {}}
1299a1a7e112Sdan
13002fae1504Sdando_execsql_test 11.0 {
13012fae1504Sdan  DROP VIEW IF EXISTS v8;
13022fae1504Sdan  DROP TABLE IF EXISTS t8;
13032fae1504Sdan  CREATE TABLE t8(t INT, total INT);
13042fae1504Sdan  INSERT INTO t8 VALUES(0,2);
13052fae1504Sdan  INSERT INTO t8 VALUES(5,1);
13062fae1504Sdan  INSERT INTO t8 VALUES(10,1);
13072fae1504Sdan} {}
13082fae1504Sdan
13092fae1504Sdando_execsql_test 11.1 {
13102fae1504Sdan  SELECT NTILE(256) OVER (ORDER BY total) - 1 AS nt FROM t8;
13112fae1504Sdan} {0   1   2}
13122fae1504Sdan
13132fae1504Sdando_execsql_test 11.2 {
13142fae1504Sdan  CREATE VIEW v8 AS SELECT NTILE(256) OVER (ORDER BY total) - 1 AS nt FROM t8;
13152fae1504Sdan} {}
13162fae1504Sdan
13172fae1504Sdando_execsql_test 11.3 {
13182fae1504Sdan  SELECT * FROM v8;
13192fae1504Sdan} {0   1   2}
13202fae1504Sdan
13212fae1504Sdando_execsql_test 11.4 {
13222fae1504Sdan  SELECT * FROM (
13232fae1504Sdan    SELECT NTILE(256) OVER (ORDER BY total) - 1 AS nt FROM t8
13242fae1504Sdan  ) sub;
13252fae1504Sdan} {0   1   2}
13262fae1504Sdan
1327*553948e5Sdando_execsql_test 11.5 {
1328*553948e5Sdan  SELECT sum( min(t) ) OVER () FROM t8 GROUP BY total;
1329*553948e5Sdan} {5   5}
1330*553948e5Sdan
1331*553948e5Sdando_execsql_test 11.5 {
1332*553948e5Sdan  SELECT sum( max(t) ) OVER () FROM t8 GROUP BY total;
1333*553948e5Sdan} {10   10}
1334*553948e5Sdan
1335*553948e5Sdando_execsql_test 11.7 {
1336*553948e5Sdan  SELECT sum( min(t) ) OVER () FROM t8;
1337*553948e5Sdan} {0}
1338*553948e5Sdan
1339*553948e5Sdando_execsql_test 11.8 {
1340*553948e5Sdan  SELECT sum( max(t) ) OVER () FROM t8;
1341*553948e5Sdan} {10}
1342*553948e5Sdan
1343b6299681Sdando_execsql_test 12.0 {
1344b6299681Sdan  DROP TABLE IF EXISTS t2;
1345b6299681Sdan  CREATE TABLE t2(a INTEGER);
1346b6299681Sdan  INSERT INTO t2 VALUES(1), (2), (3);
1347b6299681Sdan} {}
1348b6299681Sdan
1349b6299681Sdando_execsql_test 12.1 {
1350b6299681Sdan  SELECT (SELECT min(a) OVER ()) FROM t2
1351b6299681Sdan} {1   2   3}
1352b6299681Sdan
1353b6299681Sdan
1354b6299681Sdando_test 12.2 {
1355b6299681Sdan  set myres {}
1356b6299681Sdan  foreach r [db eval {SELECT (SELECT avg(a)) FROM t2 ORDER BY 1}] {
1357b6299681Sdan    lappend myres [format %.4f [set r]]
1358b6299681Sdan  }
1359b6299681Sdan  set res2 {2.0000}
1360b6299681Sdan  set i 0
1361b6299681Sdan  foreach r [set myres] r2 [set res2] {
1362b6299681Sdan    if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
1363b6299681Sdan      error "list element [set i] does not match: got=[set r] expected=[set r2]"
1364b6299681Sdan    }
1365b6299681Sdan    incr i
1366b6299681Sdan  }
1367b6299681Sdan  set {} {}
1368b6299681Sdan} {}
1369b6299681Sdan
1370b6299681Sdan
1371b6299681Sdando_test 12.3 {
1372b6299681Sdan  set myres {}
1373b6299681Sdan  foreach r [db eval {SELECT
1374b6299681Sdan    (SELECT avg(a) UNION SELECT min(a) OVER ())
1375b6299681Sdan  FROM t2 GROUP BY a
1376b6299681Sdan  ORDER BY 1}] {
1377b6299681Sdan    lappend myres [format %.4f [set r]]
1378b6299681Sdan  }
1379b6299681Sdan  set res2 {1.0000 2.0000 3.0000}
1380b6299681Sdan  set i 0
1381b6299681Sdan  foreach r [set myres] r2 [set res2] {
1382b6299681Sdan    if {[set r]<([set r2]-0.0001) || [set r]>([set r2]+0.0001)} {
1383b6299681Sdan      error "list element [set i] does not match: got=[set r] expected=[set r2]"
1384b6299681Sdan    }
1385b6299681Sdan    incr i
1386b6299681Sdan  }
1387b6299681Sdan  set {} {}
1388b6299681Sdan} {}
1389b6299681Sdan
13906bc5c9e7Sdanfinish_test
1391