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. The
12 # focus of this script is the DISTINCT modifier on aggregate functions.
14 # $Id: distinctagg.test,v 1.3 2009/02/09 13:19:28 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 do_test distinctagg-1.1 {
22 CREATE TABLE t1(a,b,c);
23 INSERT INTO t1 VALUES(1,2,3);
24 INSERT INTO t1 VALUES(1,3,4);
25 INSERT INTO t1 VALUES(1,3,5);
26 SELECT count(distinct a),
32 do_test distinctagg-1.2 {
34 SELECT b, count(distinct c) FROM t1 GROUP BY b ORDER BY b
37 do_test distinctagg-1.3 {
39 INSERT INTO t1 SELECT a+1, b+3, c+5 FROM t1;
40 INSERT INTO t1 SELECT a+2, b+6, c+10 FROM t1;
41 INSERT INTO t1 SELECT a+4, b+12, c+20 FROM t1;
42 SELECT count(*), count(distinct a), count(distinct b) FROM t1
45 do_test distinctagg-1.4 {
47 SELECT a, count(distinct c) FROM t1 GROUP BY a ORDER BY a
49 } {1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3}
51 do_test distinctagg-2.1 {
53 SELECT count(distinct) FROM t1;
55 } {1 {DISTINCT aggregates must have exactly one argument}}
56 do_test distinctagg-2.2 {
58 SELECT group_concat(distinct a,b) FROM t1;
60 } {1 {DISTINCT aggregates must have exactly one argument}}