wasCSharpSQLite – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | # 2005 September 11 |
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. The |
||
12 | # focus of this script is the DISTINCT modifier on aggregate functions. |
||
13 | # |
||
14 | # $Id: distinctagg.test,v 1.3 2009/02/09 13:19:28 drh Exp $ |
||
15 | |||
16 | |||
17 | set testdir [file dirname $argv0] |
||
18 | source $testdir/tester.tcl |
||
19 | |||
20 | do_test distinctagg-1.1 { |
||
21 | execsql { |
||
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), |
||
27 | count(distinct b), |
||
28 | count(distinct c), |
||
29 | count(all a) FROM t1; |
||
30 | } |
||
31 | } {1 2 3 3} |
||
32 | do_test distinctagg-1.2 { |
||
33 | execsql { |
||
34 | SELECT b, count(distinct c) FROM t1 GROUP BY b ORDER BY b |
||
35 | } |
||
36 | } {2 1 3 2} |
||
37 | do_test distinctagg-1.3 { |
||
38 | execsql { |
||
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 |
||
43 | } |
||
44 | } {24 8 16} |
||
45 | do_test distinctagg-1.4 { |
||
46 | execsql { |
||
47 | SELECT a, count(distinct c) FROM t1 GROUP BY a ORDER BY a |
||
48 | } |
||
49 | } {1 3 2 3 3 3 4 3 5 3 6 3 7 3 8 3} |
||
50 | |||
51 | do_test distinctagg-2.1 { |
||
52 | catchsql { |
||
53 | SELECT count(distinct) FROM t1; |
||
54 | } |
||
55 | } {1 {DISTINCT aggregates must have exactly one argument}} |
||
56 | do_test distinctagg-2.2 { |
||
57 | catchsql { |
||
58 | SELECT group_concat(distinct a,b) FROM t1; |
||
59 | } |
||
60 | } {1 {DISTINCT aggregates must have exactly one argument}} |
||
61 | |||
62 | finish_test |