mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-12 19:17:54 +02:00
6c1d4662af
parameter to allow it to be forced off for comparison purposes. Add ORDER BY clauses to a bunch of regression test queries that will otherwise produce randomly-ordered output in the new regime.
34 lines
1.0 KiB
SQL
34 lines
1.0 KiB
SQL
--
|
|
-- SELECT_HAVING
|
|
--
|
|
|
|
-- load test data
|
|
CREATE TABLE test_having (a int, b int, c char(8), d char);
|
|
INSERT INTO test_having VALUES (0, 1, 'XXXX', 'A');
|
|
INSERT INTO test_having VALUES (1, 2, 'AAAA', 'b');
|
|
INSERT INTO test_having VALUES (2, 2, 'AAAA', 'c');
|
|
INSERT INTO test_having VALUES (3, 3, 'BBBB', 'D');
|
|
INSERT INTO test_having VALUES (4, 3, 'BBBB', 'e');
|
|
INSERT INTO test_having VALUES (5, 3, 'bbbb', 'F');
|
|
INSERT INTO test_having VALUES (6, 4, 'cccc', 'g');
|
|
INSERT INTO test_having VALUES (7, 4, 'cccc', 'h');
|
|
INSERT INTO test_having VALUES (8, 4, 'CCCC', 'I');
|
|
INSERT INTO test_having VALUES (9, 4, 'CCCC', 'j');
|
|
|
|
SELECT b, c FROM test_having
|
|
GROUP BY b, c HAVING count(*) = 1 ORDER BY b, c;
|
|
|
|
-- HAVING is equivalent to WHERE in this case
|
|
SELECT b, c FROM test_having
|
|
GROUP BY b, c HAVING b = 3 ORDER BY b, c;
|
|
|
|
SELECT lower(c), count(c) FROM test_having
|
|
GROUP BY lower(c) HAVING count(*) > 2 OR min(a) = max(a)
|
|
ORDER BY lower(c);
|
|
|
|
SELECT c, max(a) FROM test_having
|
|
GROUP BY c HAVING count(*) > 2 OR min(a) = max(a)
|
|
ORDER BY c;
|
|
|
|
DROP TABLE test_having;
|