~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/select_having_1.out

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- SELECT_HAVING
 
3
--
 
4
-- load test data
 
5
CREATE TABLE test_having (a int, b int, c char(8), d char);
 
6
INSERT INTO test_having VALUES (0, 1, 'XXXX', 'A');
 
7
INSERT INTO test_having VALUES (1, 2, 'AAAA', 'b');
 
8
INSERT INTO test_having VALUES (2, 2, 'AAAA', 'c');
 
9
INSERT INTO test_having VALUES (3, 3, 'BBBB', 'D');
 
10
INSERT INTO test_having VALUES (4, 3, 'BBBB', 'e');
 
11
INSERT INTO test_having VALUES (5, 3, 'bbbb', 'F');
 
12
INSERT INTO test_having VALUES (6, 4, 'cccc', 'g');
 
13
INSERT INTO test_having VALUES (7, 4, 'cccc', 'h');
 
14
INSERT INTO test_having VALUES (8, 4, 'CCCC', 'I');
 
15
INSERT INTO test_having VALUES (9, 4, 'CCCC', 'j');
 
16
SELECT b, c FROM test_having
 
17
        GROUP BY b, c HAVING count(*) = 1 ORDER BY b, c;
 
18
 b |    c     
 
19
---+----------
 
20
 1 | XXXX    
 
21
 3 | bbbb    
 
22
(2 rows)
 
23
 
 
24
-- HAVING is equivalent to WHERE in this case
 
25
SELECT b, c FROM test_having
 
26
        GROUP BY b, c HAVING b = 3 ORDER BY b, c;
 
27
 b |    c     
 
28
---+----------
 
29
 3 | BBBB    
 
30
 3 | bbbb    
 
31
(2 rows)
 
32
 
 
33
SELECT lower(c), count(c) FROM test_having
 
34
        GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a)
 
35
        ORDER BY lower(c);
 
36
 lower | count 
 
37
-------+-------
 
38
 bbbb  |     3
 
39
 cccc  |     4
 
40
 xxxx  |     1
 
41
(3 rows)
 
42
 
 
43
SELECT c, max(a) FROM test_having
 
44
        GROUP BY c HAVING count(*) > 2 OR min(a) = max(a)
 
45
        ORDER BY c;
 
46
    c     | max 
 
47
----------+-----
 
48
 bbbb     |   5
 
49
 XXXX     |   0
 
50
(2 rows)
 
51
 
 
52
DROP TABLE test_having;