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 # Test cases for RANGE BETWEEN and especially with NULLS LAST
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
16 set testprefix windowA
18 ifcapable !windowfunc {
24 CREATE TABLE t1(a INTEGER PRIMARY KEY, b CHAR(1), d FLOAT);
36 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
38 (ORDER BY d DESC NULLS LAST
39 RANGE BETWEEN 2.50 PRECEDING AND 2.25 FOLLOWING)
40 ORDER BY +d DESC NULLS LAST, +a;
52 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
54 (ORDER BY d DESC NULLS FIRST
55 RANGE BETWEEN 2.50 PRECEDING AND 2.25 FOLLOWING)
56 ORDER BY +d DESC NULLS FIRST, +a;
68 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
70 (ORDER BY d DESC NULLS LAST
71 RANGE BETWEEN 2.50 PRECEDING AND UNBOUNDED FOLLOWING)
72 ORDER BY +d DESC NULLS LAST, +a;
84 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
86 (ORDER BY d DESC NULLS FIRST
87 RANGE BETWEEN 2.50 PRECEDING AND UNBOUNDED FOLLOWING)
88 ORDER BY +d DESC NULLS FIRST, +a;
100 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
102 (ORDER BY d DESC NULLS LAST
103 RANGE BETWEEN 2.50 PRECEDING AND CURRENT ROW)
104 ORDER BY +d DESC NULLS LAST, +a;
115 do_execsql_test 1.6 {
116 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
118 (ORDER BY d DESC NULLS FIRST
119 RANGE BETWEEN 2.50 PRECEDING AND CURRENT ROW)
120 ORDER BY +d DESC NULLS FIRST, +a;
131 do_execsql_test 2.1 {
132 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
134 (ORDER BY d DESC NULLS LAST
135 RANGE BETWEEN UNBOUNDED PRECEDING AND 2.25 FOLLOWING)
136 ORDER BY +d DESC NULLS LAST, +a;
147 do_execsql_test 2.2 {
148 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
150 (ORDER BY d DESC NULLS FIRST
151 RANGE BETWEEN UNBOUNDED PRECEDING AND 2.25 FOLLOWING)
152 ORDER BY +d DESC NULLS FIRST, +a;
163 do_execsql_test 2.3 {
164 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
166 (ORDER BY d DESC NULLS LAST
167 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
168 ORDER BY +d DESC NULLS LAST, +a;
179 do_execsql_test 2.4 {
180 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
182 (ORDER BY d DESC NULLS FIRST
183 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
184 ORDER BY +d DESC NULLS FIRST, +a;
195 do_execsql_test 2.5 {
196 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
198 (ORDER BY d DESC NULLS LAST
199 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
200 ORDER BY +d DESC NULLS LAST, +a;
211 do_execsql_test 2.6 {
212 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
214 (ORDER BY d DESC NULLS FIRST
215 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
216 ORDER BY +d DESC NULLS FIRST, +a;
228 do_execsql_test 3.1 {
229 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
231 (ORDER BY d DESC NULLS LAST
232 RANGE BETWEEN CURRENT ROW AND 2.25 FOLLOWING)
233 ORDER BY +d DESC NULLS LAST, +a;
244 do_execsql_test 3.2 {
245 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
247 (ORDER BY d DESC NULLS FIRST
248 RANGE BETWEEN CURRENT ROW AND 2.25 FOLLOWING)
249 ORDER BY +d DESC NULLS FIRST, +a;
260 do_execsql_test 3.3 {
261 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
263 (ORDER BY d DESC NULLS LAST
264 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
265 ORDER BY +d DESC NULLS LAST, +a;
276 do_execsql_test 3.4 {
277 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
279 (ORDER BY d DESC NULLS FIRST
280 RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
281 ORDER BY +d DESC NULLS FIRST, +a;
292 do_execsql_test 4.0 {
293 SELECT a, b, quote(d), group_concat(b,'') OVER w1 FROM t1
295 (ORDER BY d DESC NULLS FIRST
296 RANGE BETWEEN 2.50 PRECEDING AND 0.5 PRECEDING)
297 ORDER BY +d DESC NULLS FIRST, +a;