3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
14 ####################################################
15 # DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
16 ####################################################
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
20 set testprefix window4
22 ifcapable !windowfunc { finish_test ; return }
24 DROP TABLE IF EXISTS t3;
25 CREATE TABLE t3(a TEXT PRIMARY KEY);
26 INSERT INTO t3 VALUES('a'), ('b'), ('c'), ('d'), ('e');
27 INSERT INTO t3 VALUES('f'), ('g'), ('h'), ('i'), ('j');
31 SELECT a, ntile(1) OVER (ORDER BY a) FROM t3
32 } {a 1 b 1 c 1 d 1 e 1 f 1 g 1 h 1 i 1 j 1}
35 SELECT a, ntile(2) OVER (ORDER BY a) FROM t3
36 } {a 1 b 1 c 1 d 1 e 1 f 2 g 2 h 2 i 2 j 2}
39 SELECT a, ntile(3) OVER (ORDER BY a) FROM t3
40 } {a 1 b 1 c 1 d 1 e 2 f 2 g 2 h 3 i 3 j 3}
43 SELECT a, ntile(4) OVER (ORDER BY a) FROM t3
44 } {a 1 b 1 c 1 d 2 e 2 f 2 g 3 h 3 i 4 j 4}
47 SELECT a, ntile(5) OVER (ORDER BY a) FROM t3
48 } {a 1 b 1 c 2 d 2 e 3 f 3 g 4 h 4 i 5 j 5}
51 SELECT a, ntile(6) OVER (ORDER BY a) FROM t3
52 } {a 1 b 1 c 2 d 2 e 3 f 3 g 4 h 4 i 5 j 6}
55 SELECT a, ntile(7) OVER (ORDER BY a) FROM t3
56 } {a 1 b 1 c 2 d 2 e 3 f 3 g 4 h 5 i 6 j 7}
59 SELECT a, ntile(8) OVER (ORDER BY a) FROM t3
60 } {a 1 b 1 c 2 d 2 e 3 f 4 g 5 h 6 i 7 j 8}
63 SELECT a, ntile(9) OVER (ORDER BY a) FROM t3
64 } {a 1 b 1 c 2 d 3 e 4 f 5 g 6 h 7 i 8 j 9}
66 do_execsql_test 1.10 {
67 SELECT a, ntile(10) OVER (ORDER BY a) FROM t3
68 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
70 do_execsql_test 1.11 {
71 SELECT a, ntile(11) OVER (ORDER BY a) FROM t3
72 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
74 do_execsql_test 1.12 {
75 SELECT a, ntile(12) OVER (ORDER BY a) FROM t3
76 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
78 do_execsql_test 1.13 {
79 SELECT a, ntile(13) OVER (ORDER BY a) FROM t3
80 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
82 do_execsql_test 1.14 {
83 SELECT a, ntile(14) OVER (ORDER BY a) FROM t3
84 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
86 do_execsql_test 1.15 {
87 SELECT a, ntile(15) OVER (ORDER BY a) FROM t3
88 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
90 do_execsql_test 1.16 {
91 SELECT a, ntile(16) OVER (ORDER BY a) FROM t3
92 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
94 do_execsql_test 1.17 {
95 SELECT a, ntile(17) OVER (ORDER BY a) FROM t3
96 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
98 do_execsql_test 1.18 {
99 SELECT a, ntile(18) OVER (ORDER BY a) FROM t3
100 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
102 do_execsql_test 1.19 {
103 SELECT a, ntile(19) OVER (ORDER BY a) FROM t3
104 } {a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10}
106 do_execsql_test 2.0 {
107 DROP TABLE IF EXISTS t4;
108 CREATE TABLE t4(a INTEGER PRIMARY KEY, b TEXT, c INTEGER);
109 INSERT INTO t4 VALUES(1, 'A', 9);
110 INSERT INTO t4 VALUES(2, 'B', 3);
111 INSERT INTO t4 VALUES(3, 'C', 2);
112 INSERT INTO t4 VALUES(4, 'D', 10);
113 INSERT INTO t4 VALUES(5, 'E', 5);
114 INSERT INTO t4 VALUES(6, 'F', 1);
115 INSERT INTO t4 VALUES(7, 'G', 1);
116 INSERT INTO t4 VALUES(8, 'H', 2);
117 INSERT INTO t4 VALUES(9, 'I', 10);
118 INSERT INTO t4 VALUES(10, 'J', 4);
121 do_execsql_test 2.1 {
122 SELECT a, nth_value(b, c) OVER (ORDER BY a) FROM t4
123 } {1 {} 2 {} 3 B 4 {} 5 E 6 A 7 A 8 B 9 {} 10 D}
125 do_execsql_test 2.2.1 {
126 SELECT a, lead(b) OVER (ORDER BY a) FROM t4
127 } {1 B 2 C 3 D 4 E 5 F 6 G 7 H 8 I 9 J 10 {}}
129 do_execsql_test 2.2.2 {
130 SELECT a, lead(b, 2) OVER (ORDER BY a) FROM t4
131 } {1 C 2 D 3 E 4 F 5 G 6 H 7 I 8 J 9 {} 10 {}}
133 do_execsql_test 2.2.3 {
134 SELECT a, lead(b, 3, 'abc') OVER (ORDER BY a) FROM t4
135 } {1 D 2 E 3 F 4 G 5 H 6 I 7 J 8 abc 9 abc 10 abc}
137 do_execsql_test 2.3.1 {
138 SELECT a, lag(b) OVER (ORDER BY a) FROM t4
139 } {1 {} 2 A 3 B 4 C 5 D 6 E 7 F 8 G 9 H 10 I}
141 do_execsql_test 2.3.2 {
142 SELECT a, lag(b, 2) OVER (ORDER BY a) FROM t4
143 } {1 {} 2 {} 3 A 4 B 5 C 6 D 7 E 8 F 9 G 10 H}
145 do_execsql_test 2.3.3 {
146 SELECT a, lag(b, 3, 'abc') OVER (ORDER BY a) FROM t4
147 } {1 abc 2 abc 3 abc 4 A 5 B 6 C 7 D 8 E 9 F 10 G}
149 do_execsql_test 2.4.1 {
150 SELECT group_concat(b, '.') OVER (
151 ORDER BY a ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
153 } {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 E.F.G.H.I.J F.G.H.I.J G.H.I.J H.I.J I.J J}
155 do_execsql_test 3.0 {
156 DROP TABLE IF EXISTS t5;
157 CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
158 INSERT INTO t5 VALUES(1, 'A', 'one', 5);
159 INSERT INTO t5 VALUES(2, 'B', 'two', 4);
160 INSERT INTO t5 VALUES(3, 'A', 'three', 3);
161 INSERT INTO t5 VALUES(4, 'B', 'four', 2);
162 INSERT INTO t5 VALUES(5, 'A', 'five', 1);
165 do_execsql_test 3.1 {
166 SELECT a, nth_value(c, d) OVER (ORDER BY b) FROM t5
167 } {1 {} 3 five 5 one 2 two 4 three}
169 do_execsql_test 3.2 {
170 SELECT a, nth_value(c, d) OVER (PARTITION BY b ORDER BY a) FROM t5
171 } {1 {} 3 {} 5 one 2 {} 4 four}
173 do_execsql_test 3.3 {
174 SELECT a, count(*) OVER abc, count(*) OVER def FROM t5
175 WINDOW abc AS (ORDER BY a),
176 def AS (ORDER BY a DESC)
178 } {1 1 5 2 2 4 3 3 3 4 4 2 5 5 1}
180 do_execsql_test 3.4 {
181 SELECT a, max(a) FILTER (WHERE (a%2)=0) OVER w FROM t5
182 WINDOW w AS (ORDER BY a)
183 } {1 {} 2 2 3 2 4 4 5 4}
185 do_execsql_test 3.5.1 {
186 SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 2 PRECEDING)
188 } {1 {} 2 {} 3 {} 4 {} 5 {}}
190 do_execsql_test 3.5.2 {
191 SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
193 } {1 {} 2 one 3 two 4 three 5 four}
195 do_execsql_test 3.5.3 {
196 SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 PRECEDING AND 0 PRECEDING)
198 } {1 one 2 two 3 three 4 four 5 five}
200 do_execsql_test 3.6.1 {
201 SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 2 FOLLOWING AND 1 FOLLOWING)
203 } {1 {} 2 {} 3 {} 4 {} 5 {}}
205 do_execsql_test 3.6.2 {
206 SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING)
208 } {1 two 2 three 3 four 4 five 5 {}}
210 do_execsql_test 3.6.3 {
211 SELECT a, max(c) OVER (ORDER BY a ROWS BETWEEN 0 FOLLOWING AND 0 FOLLOWING)
213 } {1 one 2 two 3 three 4 four 5 five}
215 #==========================================================================
217 do_execsql_test 4.0 {
218 DROP TABLE IF EXISTS ttt;
219 CREATE TABLE ttt(a INTEGER PRIMARY KEY, b INTEGER, c INTEGER);
220 INSERT INTO ttt VALUES(1, 1, 1);
221 INSERT INTO ttt VALUES(2, 2, 2);
222 INSERT INTO ttt VALUES(3, 3, 3);
224 INSERT INTO ttt VALUES(4, 1, 2);
225 INSERT INTO ttt VALUES(5, 2, 3);
226 INSERT INTO ttt VALUES(6, 3, 4);
228 INSERT INTO ttt VALUES(7, 1, 3);
229 INSERT INTO ttt VALUES(8, 2, 4);
230 INSERT INTO ttt VALUES(9, 3, 5);
233 do_execsql_test 4.1 {
234 SELECT max(c), max(b) OVER (ORDER BY b) FROM ttt GROUP BY b;
237 do_execsql_test 4.2 {
238 SELECT max(b) OVER (ORDER BY max(c)) FROM ttt GROUP BY b;
241 do_execsql_test 4.3 {
242 SELECT abs(max(b) OVER (ORDER BY b)) FROM ttt GROUP BY b;
245 do_execsql_test 4.4 {
247 ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
249 } {18 17 15 12 11 9 6 5 3}
251 do_execsql_test 4.5.1.1 {
252 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
253 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
255 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
257 do_execsql_test 4.5.1.2 {
258 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
259 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
261 } {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
263 do_execsql_test 4.5.2.1 {
264 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
265 min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
267 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
269 do_execsql_test 4.5.2.2 {
270 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
271 sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
273 } {1 1 2 2 3 3 3 2 5 3 7 4 6 3 9 4 12 5}
275 do_execsql_test 4.5.3.1 {
276 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
277 min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
279 } {1 1 2 1 3 1 2 1 3 1 4 1 3 1 4 1 5 1}
281 do_execsql_test 4.5.3.2 {
282 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
283 sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
285 } {1 1 2 3 3 6 3 8 5 11 7 15 6 18 9 22 12 27}
287 do_execsql_test 4.5.4.1 {
288 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
289 min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
291 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
293 do_execsql_test 4.5.4.2 {
294 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
295 sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
297 } {1 1 2 2 3 3 3 2 5 3 7 4 6 3 9 4 12 5}
299 do_execsql_test 4.5.5.1 {
300 SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
301 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
303 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
305 do_execsql_test 4.5.5.2 {
306 SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
307 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
309 } {1 1 2 2 3 3 2 3 3 5 4 7 3 6 4 9 5 12}
311 do_execsql_test 4.5.6.1 {
312 SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
313 min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
315 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
317 do_execsql_test 4.5.6.2 {
318 SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
319 sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
321 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
323 do_execsql_test 4.5.7.1 {
324 SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
325 min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
327 } {1 1 2 1 3 1 2 1 3 1 4 1 3 1 4 1 5 1}
329 do_execsql_test 4.5.7.2 {
330 SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
331 sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
333 } {1 1 2 3 3 6 2 8 3 11 4 15 3 18 4 22 5 27}
335 do_execsql_test 4.5.8.1 {
336 SELECT max(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
337 min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
339 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
341 do_execsql_test 4.5.8.2 {
342 SELECT sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
343 sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
345 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
347 do_execsql_test 4.5.9.1 {
348 SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
349 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
351 } {1 1 2 2 3 3 3 1 3 2 4 3 4 1 4 2 5 3}
353 do_execsql_test 4.5.9.2 {
354 SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
355 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
357 } {1 1 3 2 6 3 8 3 11 5 15 7 18 6 22 9 27 12}
359 do_execsql_test 4.5.10.1 {
360 SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
361 min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
363 } {1 1 2 2 3 3 3 2 3 3 4 4 4 3 4 4 5 5}
365 do_execsql_test 4.5.10.2 {
366 SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
367 sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
369 } {1 1 3 2 6 3 8 2 11 3 15 4 18 3 22 4 27 5}
371 do_execsql_test 4.5.11.1 {
372 SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
373 min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
375 } {1 1 2 1 3 1 3 1 3 1 4 1 4 1 4 1 5 1}
377 do_execsql_test 4.5.11.2 {
378 SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
379 sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
381 } {1 1 3 3 6 6 8 8 11 11 15 15 18 18 22 22 27 27}
383 do_execsql_test 4.5.12.1 {
384 SELECT max(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
385 min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
387 } {1 1 2 2 3 3 3 2 3 3 4 4 4 3 4 4 5 5}
389 do_execsql_test 4.5.12.2 {
390 SELECT sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
391 sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
393 } {1 1 3 2 6 3 8 2 11 3 15 4 18 3 22 4 27 5}
395 do_execsql_test 4.5.13.1 {
396 SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
397 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
399 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
401 do_execsql_test 4.5.13.2 {
402 SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
403 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
405 } {1 1 2 2 3 3 2 3 3 5 4 7 3 6 4 9 5 12}
407 do_execsql_test 4.5.14.1 {
408 SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
409 min(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
411 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
413 do_execsql_test 4.5.14.2 {
414 SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
415 sum(c) OVER (PARTITION BY b, a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
417 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
419 do_execsql_test 4.5.15.1 {
420 SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
421 min(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
423 } {1 1 2 1 3 1 2 1 3 1 4 1 3 1 4 1 5 1}
425 do_execsql_test 4.5.15.2 {
426 SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
427 sum(c) OVER ( ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
429 } {1 1 2 3 3 6 2 8 3 11 4 15 3 18 4 22 5 27}
431 do_execsql_test 4.5.16.1 {
432 SELECT max(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
433 min(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
435 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
437 do_execsql_test 4.5.16.2 {
438 SELECT sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
439 sum(c) OVER (PARTITION BY a ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
441 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
443 do_execsql_test 4.5.17.1 {
444 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
445 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
447 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
449 do_execsql_test 4.5.17.2 {
450 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
451 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
453 } {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
455 do_execsql_test 4.5.18.1 {
456 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
457 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
459 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
461 do_execsql_test 4.5.18.2 {
462 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
463 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
465 } {1 6 2 9 3 12 3 6 5 9 7 12 6 6 9 9 12 12}
467 do_execsql_test 4.5.19.1 {
468 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
469 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
471 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
473 do_execsql_test 4.5.19.2 {
474 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
475 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
477 } {1 1 2 2 3 3 3 2 5 3 7 4 6 3 9 4 12 5}
479 do_execsql_test 4.5.20.1 {
480 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
481 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
483 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
485 do_execsql_test 4.5.20.2 {
486 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
487 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
489 } {1 6 2 9 3 12 3 5 5 7 7 9 6 3 9 4 12 5}
491 do_execsql_test 4.5.21.1 {
492 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
493 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
495 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
497 do_execsql_test 4.5.21.2 {
498 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
499 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
501 } {6 1 9 2 12 3 6 3 9 5 12 7 6 6 9 9 12 12}
503 do_execsql_test 4.5.22.1 {
504 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
505 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
507 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
509 do_execsql_test 4.5.22.2 {
510 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
511 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
513 } {6 6 9 9 12 12 6 6 9 9 12 12 6 6 9 9 12 12}
515 do_execsql_test 4.5.23.1 {
516 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
517 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
519 } {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
521 do_execsql_test 4.5.23.2 {
522 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
523 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
525 } {6 1 9 2 12 3 6 2 9 3 12 4 6 3 9 4 12 5}
527 do_execsql_test 4.5.24.1 {
528 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
529 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
531 } {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
533 do_execsql_test 4.5.24.2 {
534 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING),
535 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
537 } {6 6 9 9 12 12 6 5 9 7 12 9 6 3 9 4 12 5}
539 do_execsql_test 4.5.25.1 {
540 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
541 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
543 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
545 do_execsql_test 4.5.25.2 {
546 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
547 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
549 } {1 1 2 2 3 3 2 3 3 5 4 7 3 6 4 9 5 12}
551 do_execsql_test 4.5.26.1 {
552 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
553 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
555 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
557 do_execsql_test 4.5.26.2 {
558 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
559 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
561 } {1 6 2 9 3 12 2 6 3 9 4 12 3 6 4 9 5 12}
563 do_execsql_test 4.5.27.1 {
564 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
565 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
567 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
569 do_execsql_test 4.5.27.2 {
570 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
571 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
573 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
575 do_execsql_test 4.5.28.1 {
576 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
577 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
579 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
581 do_execsql_test 4.5.28.2 {
582 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW),
583 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
585 } {1 6 2 9 3 12 2 5 3 7 4 9 3 3 4 4 5 5}
587 do_execsql_test 4.5.29.1 {
588 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
589 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
591 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
593 do_execsql_test 4.5.29.2 {
594 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
595 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
597 } {6 1 9 2 12 3 5 3 7 5 9 7 3 6 4 9 5 12}
599 do_execsql_test 4.5.30.1 {
600 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
601 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
603 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
605 do_execsql_test 4.5.30.2 {
606 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
607 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
609 } {6 6 9 9 12 12 5 6 7 9 9 12 3 6 4 9 5 12}
611 do_execsql_test 4.5.31.1 {
612 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
613 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
615 } {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
617 do_execsql_test 4.5.31.2 {
618 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
619 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND CURRENT ROW)
621 } {6 1 9 2 12 3 5 2 7 3 9 4 3 3 4 4 5 5}
623 do_execsql_test 4.5.32.1 {
624 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
625 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
627 } {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
629 do_execsql_test 4.5.32.2 {
630 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING),
631 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
633 } {6 6 9 9 12 12 5 5 7 7 9 9 3 3 4 4 5 5}
635 do_execsql_test 4.5.33.1 {
636 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
637 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
639 } {2 1 3 2 4 3 3 1 4 2 5 3 3 1 4 2 5 3}
641 do_execsql_test 4.5.33.2 {
642 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
643 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
645 } {3 3 5 5 7 7 6 6 9 9 12 12 6 6 9 9 12 12}
647 do_execsql_test 4.5.34.1 {
648 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
649 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
651 } {2 1 3 2 4 3 3 1 4 2 5 3 3 1 4 2 5 3}
653 do_execsql_test 4.5.34.2 {
654 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
655 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
657 } {3 6 5 9 7 12 6 6 9 9 12 12 6 6 9 9 12 12}
659 do_execsql_test 4.5.35.1 {
660 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
661 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
663 } {2 {} 3 {} 4 {} 3 1 4 2 5 3 3 2 4 3 5 4}
665 do_execsql_test 4.5.35.2 {
666 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
667 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
669 } {3 {} 5 {} 7 {} 6 1 9 2 12 3 6 2 9 3 12 4}
671 do_execsql_test 4.5.36.1 {
672 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
673 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
675 } {2 {} 3 {} 4 {} 3 {} 4 {} 5 {} 3 {} 4 {} 5 {}}
677 do_execsql_test 4.5.36.2 {
678 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
679 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
681 } {3 {} 5 {} 7 {} 6 {} 9 {} 12 {} 6 {} 9 {} 12 {}}
683 do_execsql_test 4.5.37.1 {
684 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
685 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
687 } {2 2 3 3 4 4 3 3 4 4 5 5 3 {} 4 {} 5 {}}
689 do_execsql_test 4.5.37.2 {
690 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING),
691 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
693 } {3 5 5 7 7 9 6 3 9 4 12 5 6 {} 9 {} 12 {}}
695 do_execsql_test 4.5.38.1 {
696 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
697 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
699 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
701 do_execsql_test 4.5.38.2 {
702 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
703 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
705 } {6 3 9 5 12 7 6 6 9 9 12 12 6 6 9 9 12 12}
707 do_execsql_test 4.5.39.1 {
708 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
709 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
711 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
713 do_execsql_test 4.5.39.2 {
714 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
715 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
717 } {6 6 9 9 12 12 6 6 9 9 12 12 6 6 9 9 12 12}
719 do_execsql_test 4.5.40.1 {
720 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
721 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
723 } {3 {} 4 {} 5 {} 3 1 4 2 5 3 3 2 4 3 5 4}
725 do_execsql_test 4.5.40.2 {
726 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
727 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
729 } {6 {} 9 {} 12 {} 6 1 9 2 12 3 6 2 9 3 12 4}
731 do_execsql_test 4.5.41.1 {
732 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
733 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
735 } {3 {} 4 {} 5 {} 3 {} 4 {} 5 {} 3 {} 4 {} 5 {}}
737 do_execsql_test 4.5.41.2 {
738 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
739 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
741 } {6 {} 9 {} 12 {} 6 {} 9 {} 12 {} 6 {} 9 {} 12 {}}
743 do_execsql_test 4.5.42.1 {
744 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
745 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
747 } {3 2 4 3 5 4 3 3 4 4 5 5 3 {} 4 {} 5 {}}
749 do_execsql_test 4.5.42.2 {
750 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING),
751 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
753 } {6 5 9 7 12 9 6 3 9 4 12 5 6 {} 9 {} 12 {}}
755 do_execsql_test 4.5.43.1 {
756 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
757 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
759 } {{} 1 {} 2 {} 3 1 1 2 2 3 3 2 1 3 2 4 3}
761 do_execsql_test 4.5.43.2 {
762 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
763 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
765 } {{} 3 {} 5 {} 7 1 6 2 9 3 12 2 6 3 9 4 12}
767 do_execsql_test 4.5.44.1 {
768 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
769 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
771 } {{} 1 {} 2 {} 3 1 1 2 2 3 3 2 1 3 2 4 3}
773 do_execsql_test 4.5.44.2 {
774 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
775 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
777 } {{} 6 {} 9 {} 12 1 6 2 9 3 12 2 6 3 9 4 12}
779 do_execsql_test 4.5.45.1 {
780 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
781 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
783 } {{} {} {} {} {} {} 1 1 2 2 3 3 2 2 3 3 4 4}
785 do_execsql_test 4.5.45.2 {
786 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
787 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
789 } {{} {} {} {} {} {} 1 1 2 2 3 3 2 2 3 3 4 4}
791 do_execsql_test 4.5.46.1 {
792 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
793 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
795 } {{} {} {} {} {} {} 1 {} 2 {} 3 {} 2 {} 3 {} 4 {}}
797 do_execsql_test 4.5.46.2 {
798 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
799 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
801 } {{} {} {} {} {} {} 1 {} 2 {} 3 {} 2 {} 3 {} 4 {}}
803 do_execsql_test 4.5.47.1 {
804 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
805 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
807 } {{} 2 {} 3 {} 4 1 3 2 4 3 5 2 {} 3 {} 4 {}}
809 do_execsql_test 4.5.47.2 {
810 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING),
811 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
813 } {{} 5 {} 7 {} 9 1 3 2 4 3 5 2 {} 3 {} 4 {}}
815 do_execsql_test 4.5.48.1 {
816 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
817 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
819 } {{} 1 {} 2 {} 3 {} 1 {} 2 {} 3 {} 1 {} 2 {} 3}
821 do_execsql_test 4.5.48.2 {
822 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
823 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
825 } {{} 3 {} 5 {} 7 {} 6 {} 9 {} 12 {} 6 {} 9 {} 12}
827 do_execsql_test 4.5.49.1 {
828 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
829 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
831 } {{} 1 {} 2 {} 3 {} 1 {} 2 {} 3 {} 1 {} 2 {} 3}
833 do_execsql_test 4.5.49.2 {
834 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
835 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
837 } {{} 6 {} 9 {} 12 {} 6 {} 9 {} 12 {} 6 {} 9 {} 12}
839 do_execsql_test 4.5.50.1 {
840 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
841 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
843 } {{} {} {} {} {} {} {} 1 {} 2 {} 3 {} 2 {} 3 {} 4}
845 do_execsql_test 4.5.50.2 {
846 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
847 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
849 } {{} {} {} {} {} {} {} 1 {} 2 {} 3 {} 2 {} 3 {} 4}
851 do_execsql_test 4.5.51.1 {
852 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
853 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
855 } {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}}
857 do_execsql_test 4.5.51.2 {
858 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
859 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
861 } {{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}}
863 do_execsql_test 4.5.52.1 {
864 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
865 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
867 } {{} 2 {} 3 {} 4 {} 3 {} 4 {} 5 {} {} {} {} {} {}}
869 do_execsql_test 4.5.52.2 {
870 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING),
871 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
873 } {{} 5 {} 7 {} 9 {} 3 {} 4 {} 5 {} {} {} {} {} {}}
875 do_execsql_test 4.5.53.1 {
876 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
877 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
879 } {3 1 4 2 5 3 3 1 4 2 5 3 {} 1 {} 2 {} 3}
881 do_execsql_test 4.5.53.2 {
882 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
883 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 1 FOLLOWING)
885 } {5 3 7 5 9 7 3 6 4 9 5 12 {} 6 {} 9 {} 12}
887 do_execsql_test 4.5.54.1 {
888 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
889 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
891 } {3 1 4 2 5 3 3 1 4 2 5 3 {} 1 {} 2 {} 3}
893 do_execsql_test 4.5.54.2 {
894 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
895 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 3 PRECEDING AND 2 FOLLOWING)
897 } {5 6 7 9 9 12 3 6 4 9 5 12 {} 6 {} 9 {} 12}
899 do_execsql_test 4.5.55.1 {
900 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
901 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
903 } {3 {} 4 {} 5 {} 3 1 4 2 5 3 {} 2 {} 3 {} 4}
905 do_execsql_test 4.5.55.2 {
906 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
907 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING)
909 } {5 {} 7 {} 9 {} 3 1 4 2 5 3 {} 2 {} 3 {} 4}
911 do_execsql_test 4.5.56.1 {
912 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
913 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
915 } {3 {} 4 {} 5 {} 3 {} 4 {} 5 {} {} {} {} {} {} {}}
917 do_execsql_test 4.5.56.2 {
918 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
919 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 0 PRECEDING AND 1 PRECEDING)
921 } {5 {} 7 {} 9 {} 3 {} 4 {} 5 {} {} {} {} {} {} {}}
923 do_execsql_test 4.5.57.1 {
924 SELECT max(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
925 min(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
927 } {3 2 4 3 5 4 3 3 4 4 5 5 {} {} {} {} {} {}}
929 do_execsql_test 4.5.57.2 {
930 SELECT sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING),
931 sum(c) OVER (PARTITION BY b ORDER BY a ROWS BETWEEN 1 FOLLOWING AND 500 FOLLOWING)
933 } {5 5 7 7 9 9 3 3 4 4 5 5 {} {} {} {} {} {}}
935 do_execsql_test 4.5.58.1 {
936 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
937 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
939 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
941 do_execsql_test 4.5.58.2 {
942 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
943 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
945 } {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
947 do_execsql_test 4.5.59.1 {
948 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
949 min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
951 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
953 do_execsql_test 4.5.59.2 {
954 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
955 sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
957 } {1 6 2 9 3 12 3 5 5 7 7 9 6 3 9 4 12 5}
959 do_execsql_test 4.5.60.1 {
960 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
961 min(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
963 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
965 do_execsql_test 4.5.60.2 {
966 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
967 sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
969 } {1 6 2 9 3 12 3 6 5 9 7 12 6 6 9 9 12 12}
971 do_execsql_test 4.5.61.1 {
972 SELECT max(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
973 min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
975 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
977 do_execsql_test 4.5.61.2 {
978 SELECT sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
979 sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
981 } {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
983 do_execsql_test 4.5.62.1 {
984 SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
985 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
987 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
989 do_execsql_test 4.5.62.2 {
990 SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
991 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
993 } {6 1 9 2 12 3 5 3 7 5 9 7 3 6 4 9 5 12}
995 do_execsql_test 4.5.63.1 {
996 SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
997 min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
999 } {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
1001 do_execsql_test 4.5.63.2 {
1002 SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1003 sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1005 } {6 6 9 9 12 12 5 5 7 7 9 9 3 3 4 4 5 5}
1007 do_execsql_test 4.5.64.1 {
1008 SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1009 min(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1011 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
1013 do_execsql_test 4.5.64.2 {
1014 SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1015 sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1017 } {6 6 9 9 12 12 5 6 7 9 9 12 3 6 4 9 5 12}
1019 do_execsql_test 4.5.65.1 {
1020 SELECT max(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1021 min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1023 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
1025 do_execsql_test 4.5.65.2 {
1026 SELECT sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1027 sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1029 } {6 1 9 2 12 3 5 3 7 5 9 7 3 6 4 9 5 12}
1031 do_execsql_test 4.5.66.1 {
1032 SELECT max(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1033 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1035 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
1037 do_execsql_test 4.5.66.2 {
1038 SELECT sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1039 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1041 } {6 1 9 2 12 3 6 3 9 5 12 7 6 6 9 9 12 12}
1043 do_execsql_test 4.5.67.1 {
1044 SELECT max(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1045 min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1047 } {3 1 4 2 5 3 3 2 4 3 5 4 3 3 4 4 5 5}
1049 do_execsql_test 4.5.67.2 {
1050 SELECT sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1051 sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1053 } {6 6 9 9 12 12 6 5 9 7 12 9 6 3 9 4 12 5}
1055 do_execsql_test 4.5.68.1 {
1056 SELECT max(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1057 min(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1059 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
1061 do_execsql_test 4.5.68.2 {
1062 SELECT sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1063 sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1065 } {6 6 9 9 12 12 6 6 9 9 12 12 6 6 9 9 12 12}
1067 do_execsql_test 4.5.69.1 {
1068 SELECT max(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1069 min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1071 } {3 1 4 2 5 3 3 1 4 2 5 3 3 1 4 2 5 3}
1073 do_execsql_test 4.5.69.2 {
1074 SELECT sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1075 sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1077 } {6 1 9 2 12 3 6 3 9 5 12 7 6 6 9 9 12 12}
1079 do_execsql_test 4.5.70.1 {
1080 SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1081 min(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1083 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
1085 do_execsql_test 4.5.70.2 {
1086 SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1087 sum(c) OVER (PARTITION BY b ORDER BY a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1089 } {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
1091 do_execsql_test 4.5.71.1 {
1092 SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1093 min(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1095 } {1 1 2 2 3 3 2 2 3 3 4 4 3 3 4 4 5 5}
1097 do_execsql_test 4.5.71.2 {
1098 SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1099 sum(c) OVER (PARTITION BY b ORDER BY a DESC RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1101 } {1 6 2 9 3 12 3 5 5 7 7 9 6 3 9 4 12 5}
1103 do_execsql_test 4.5.72.1 {
1104 SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1105 min(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1107 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
1109 do_execsql_test 4.5.72.2 {
1110 SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1111 sum(c) OVER (PARTITION BY b RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1113 } {1 6 2 9 3 12 3 6 5 9 7 12 6 6 9 9 12 12}
1115 do_execsql_test 4.5.73.1 {
1116 SELECT max(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1117 min(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1119 } {1 1 2 2 3 3 2 1 3 2 4 3 3 1 4 2 5 3}
1121 do_execsql_test 4.5.73.2 {
1122 SELECT sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW),
1123 sum(c) OVER (PARTITION BY b ORDER BY b, a RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
1125 } {1 1 2 2 3 3 3 3 5 5 7 7 6 6 9 9 12 12}
1127 #==========================================================================
1129 do_execsql_test 7.0 {
1130 DROP TABLE IF EXISTS t1;
1131 CREATE TABLE t1(x INTEGER, y INTEGER);
1132 INSERT INTO t1 VALUES(1, 2);
1133 INSERT INTO t1 VALUES(3, 4);
1134 INSERT INTO t1 VALUES(5, 6);
1135 INSERT INTO t1 VALUES(7, 8);
1136 INSERT INTO t1 VALUES(9, 10);
1139 do_execsql_test 7.1 {
1140 SELECT lead(y) OVER win FROM t1
1141 WINDOW win AS (ORDER BY x)
1144 do_execsql_test 7.2 {
1145 SELECT lead(y, 2) OVER win FROM t1
1146 WINDOW win AS (ORDER BY x)
1149 do_execsql_test 7.3 {
1150 SELECT lead(y, 3, -1) OVER win FROM t1
1151 WINDOW win AS (ORDER BY x)
1154 do_execsql_test 7.4 {
1156 lead(y) OVER win, lead(y) OVER win
1158 WINDOW win AS (ORDER BY x)
1159 } {4 4 6 6 8 8 10 10 {} {}}
1161 do_execsql_test 7.5 {
1164 lead(y, 2) OVER win,
1165 lead(y, 3, -1) OVER win
1167 WINDOW win AS (ORDER BY x)
1168 } {4 6 8 6 8 10 8 10 -1 10 {} -1 {} {} -1}
1170 #==========================================================================
1172 do_execsql_test 8.0 {
1173 DROP TABLE IF EXISTS t1;
1174 CREATE TABLE t1(a INTEGER, b INTEGER, c INTEGER, d INTEGER);
1175 INSERT INTO t1 VALUES(1, 2, 3, 4);
1176 INSERT INTO t1 VALUES(5, 6, 7, 8);
1177 INSERT INTO t1 VALUES(9, 10, 11, 12);
1180 do_execsql_test 8.1 {
1181 SELECT row_number() OVER win,
1182 nth_value(d,2) OVER win,
1185 WINDOW win AS (ORDER BY a)
1186 } {1 {} 8 2 8 12 3 8 {}}
1188 do_execsql_test 8.2 {
1189 SELECT row_number() OVER win,
1191 dense_rank() OVER win,
1193 first_value(d) OVER win,
1194 last_value(d) OVER win,
1195 nth_value(d,2) OVER win,
1201 WINDOW win AS (ORDER BY a)
1202 } {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}
1204 #==========================================================================
1206 do_execsql_test 9.0 {
1207 DROP TABLE IF EXISTS t2;
1208 CREATE TABLE t2(x INTEGER);
1209 INSERT INTO t2 VALUES(1), (1), (1), (4), (4), (6), (7);
1212 do_execsql_test 9.1 {
1213 SELECT rank() OVER () FROM t2
1216 do_execsql_test 9.2 {
1217 SELECT dense_rank() OVER (PARTITION BY x) FROM t2
1222 foreach r [db eval {SELECT x, percent_rank() OVER (PARTITION BY x ORDER BY x) FROM t2}] {
1223 lappend myres [format %.2f [set r]]
1226 } {1.00 0.00 1.00 0.00 1.00 0.00 4.00 0.00 4.00 0.00 6.00 0.00 7.00 0.00}
1228 do_execsql_test 9.4 {
1229 SELECT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
1230 } {1 1 1 1 1 1 4 4 4 4 6 6 7 7}
1232 do_execsql_test 9.5 {
1233 SELECT DISTINCT x, rank() OVER (ORDER BY x) FROM t2 ORDER BY 1,2
1238 foreach r [db eval {SELECT percent_rank() OVER () FROM t1}] {
1239 lappend myres [format %.2f [set r]]
1246 foreach r [db eval {SELECT cume_dist() OVER () FROM t1}] {
1247 lappend myres [format %.2f [set r]]
1252 do_execsql_test 10.0 {
1253 DROP TABLE IF EXISTS t7;
1254 CREATE TABLE t7(id INTEGER PRIMARY KEY, a INTEGER, b INTEGER);
1255 INSERT INTO t7(id, a, b) VALUES
1256 (1, 1, 2), (2, 1, NULL), (3, 1, 4),
1257 (4, 3, NULL), (5, 3, 8), (6, 3, 1);
1260 do_execsql_test 10.1 {
1261 SELECT id, min(b) OVER (PARTITION BY a ORDER BY id) FROM t7;
1262 } {1 2 2 2 3 2 4 {} 5 8 6 1}
1264 do_execsql_test 10.2 {
1265 SELECT id, lead(b, -1) OVER (PARTITION BY a ORDER BY id) FROM t7;
1266 } {1 {} 2 2 3 {} 4 {} 5 {} 6 8}
1268 do_execsql_test 10.3 {
1269 SELECT id, lag(b, -1) OVER (PARTITION BY a ORDER BY id) FROM t7;
1270 } {1 {} 2 4 3 {} 4 8 5 1 6 {}}