xref: /sqlite-3.40.0/test/window2.test (revision b6e9f7a4)
1# 2018 May 19
2#
3# The author disclaims copyright to this source code.  In place of
4# a legal notice, here is a blessing:
5#
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.
9#
10#***********************************************************************
11# This file implements regression tests for SQLite library.
12#
13
14####################################################
15# DO NOT EDIT! THIS FILE IS AUTOMATICALLY GENERATED!
16####################################################
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20set testprefix window2
21
22do_execsql_test 1.0 {
23  DROP TABLE IF EXISTS t1;
24  CREATE TABLE t1(a INTEGER PRIMARY KEY, b TEXT, c TEXT, d INTEGER);
25  INSERT INTO t1 VALUES(1, 'odd',  'one',   1);
26  INSERT INTO t1 VALUES(2, 'even', 'two',   2);
27  INSERT INTO t1 VALUES(3, 'odd',  'three', 3);
28  INSERT INTO t1 VALUES(4, 'even', 'four',  4);
29  INSERT INTO t1 VALUES(5, 'odd',  'five',  5);
30  INSERT INTO t1 VALUES(6, 'even', 'six',   6);
31} {}
32
33do_execsql_test 1.1 {
34  SELECT c, sum(d) OVER (PARTITION BY b ORDER BY c) FROM t1;
35} {four 4 six 10 two 12 five 5 one 6 three 9}
36
37do_execsql_test 1.2 {
38  SELECT sum(d) OVER () FROM t1;
39} {21 21 21 21 21 21}
40
41do_execsql_test 1.3 {
42  SELECT sum(d) OVER (PARTITION BY b) FROM t1;
43} {12 12 12 9 9 9}
44
45finish_test
46