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 #***********************************************************************
13 source [file join [file dirname
$argv0] pg_common.tcl
]
15 #=========================================================================
17 start_test windowerr
"2019 March 01"
21 DROP TABLE IF EXISTS t1
;
22 CREATE TABLE t1
(a INTEGER
, b INTEGER
);
23 INSERT INTO t1 VALUES
(1, 1);
24 INSERT INTO t1 VALUES
(2, 2);
25 INSERT INTO t1 VALUES
(3, 3);
26 INSERT INTO t1 VALUES
(4, 4);
27 INSERT INTO t1 VALUES
(5, 5);
31 1 "ORDER BY a ROWS BETWEEN -1 PRECEDING AND 1 FOLLOWING"
32 2 "ORDER BY a ROWS BETWEEN 1 PRECEDING AND -1 FOLLOWING"
34 3 "ORDER BY a RANGE BETWEEN -1 PRECEDING AND 1 FOLLOWING"
35 4 "ORDER BY a RANGE BETWEEN 1 PRECEDING AND -1 FOLLOWING"
37 5 "ORDER BY a GROUPS BETWEEN -1 PRECEDING AND 1 FOLLOWING"
38 6 "ORDER BY a GROUPS BETWEEN 1 PRECEDING AND -1 FOLLOWING"
40 7 "ORDER BY a,b RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING"
42 8 "PARTITION BY a RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING"
45 SELECT a, sum(b) OVER (
51 SELECT sum
( sum
(a
) OVER
() ) FROM t1
;
55 SELECT sum
(a
) OVER
() AS xyz FROM t1 ORDER BY sum
(xyz
);
59 SELECT sum
(a
) OVER win FROM t1
60 WINDOW win AS
(ROWS BETWEEN 'hello' PRECEDING AND
10 FOLLOWING
)
63 SELECT sum
(a
) OVER win FROM t1
64 WINDOW win AS
(ROWS BETWEEN
10 PRECEDING AND x'ABCD' FOLLOWING
)
68 SELECT row_number
(a
) OVER
() FROM t1
;