Commit d8310553 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Verified output from new psql.

Include a few new tests for datetime/timespan arithmetic.
parent 24e8ca6e
This diff is collapsed.
QUERY: CREATE TABLE BOX_TBL (f1 box);
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)');
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)');
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)');
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)');
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
--
-- BOX
--
--
-- box logic
-- o
-- 3 o--|X
-- | o|
-- 2 +-+-+ |
-- | | | |
-- 1 | o-+-o
-- | |
-- 0 +---+
--
-- 0 1 2 3
--
-- boxes are specified by two points, given by four floats x1,y1,x2,y2
CREATE TABLE BOX_TBL (f1 box);
INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)');
INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)');
-- degenerate cases where the box is a line or a point
-- note that lines and points boxes all have zero area
INSERT INTO BOX_TBL (f1) VALUES ('(2.5, 2.5, 2.5,3.5)');
INSERT INTO BOX_TBL (f1) VALUES ('(3.0, 3.0,3.0,3.0)');
-- badly formatted box inputs
INSERT INTO BOX_TBL (f1) VALUES ('(2.3, 4.5)');
ERROR: Bad box external representation '(2.3, 4.5)'
QUERY: INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad');
ERROR: Bad box external representation 'asdfasdf(ad'
QUERY: SELECT '' AS four, BOX_TBL.*;
four|f1
----+-------------------
|(2,2),(0,0)
|(3,3),(1,1)
|(2.5,3.5),(2.5,2.5)
|(3,3),(3,3)
SELECT '' AS four, BOX_TBL.*;
four | f1
------+---------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
(4 rows)
QUERY: SELECT '' AS four, b.*, box_area(b.f1) as barea
SELECT '' AS four, b.*, box_area(b.f1) as barea
FROM BOX_TBL b;
four|f1 |barea
----+-------------------+-----
|(2,2),(0,0) | 4
|(3,3),(1,1) | 4
|(2.5,3.5),(2.5,2.5)| 0
|(3,3),(3,3) | 0
four | f1 | barea
------+---------------------+-------
| (2,2),(0,0) | 4
| (3,3),(1,1) | 4
| (2.5,3.5),(2.5,2.5) | 0
| (3,3),(3,3) | 0
(4 rows)
QUERY: SELECT '' AS three, b.f1
FROM BOX_TBL b
WHERE b.f1 && '(2.5,2.5,1.0,1.0)'::box;
three|f1
-----+-------------------
|(2,2),(0,0)
|(3,3),(1,1)
|(2.5,3.5),(2.5,2.5)
-- overlap
SELECT '' AS three, b.f1
FROM BOX_TBL b
WHERE b.f1 && box '(2.5,2.5,1.0,1.0)';
three | f1
-------+---------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
(3 rows)
QUERY: SELECT '' AS two, b1.*
-- left-or-overlap (x only)
SELECT '' AS two, b1.*
FROM BOX_TBL b1
WHERE b1.f1 &< '(2.0,2.0,2.5,2.5)'::box;
two|f1
---+-------------------
|(2,2),(0,0)
|(2.5,3.5),(2.5,2.5)
WHERE b1.f1 &< box '(2.0,2.0,2.5,2.5)';
two | f1
-----+---------------------
| (2,2),(0,0)
| (2.5,3.5),(2.5,2.5)
(2 rows)
QUERY: SELECT '' AS two, b1.*
-- right-or-overlap (x only)
SELECT '' AS two, b1.*
FROM BOX_TBL b1
WHERE b1.f1 &> '(2.0,2.0,2.5,2.5)'::box;
two|f1
---+-------------------
|(2.5,3.5),(2.5,2.5)
|(3,3),(3,3)
WHERE b1.f1 &> box '(2.0,2.0,2.5,2.5)';
two | f1
-----+---------------------
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
(2 rows)
QUERY: SELECT '' AS two, b.f1
-- left of
SELECT '' AS two, b.f1
FROM BOX_TBL b
WHERE b.f1 << '(3.0,3.0,5.0,5.0)'::box;
two|f1
---+-------------------
|(2,2),(0,0)
|(2.5,3.5),(2.5,2.5)
WHERE b.f1 << box '(3.0,3.0,5.0,5.0)';
two | f1
-----+---------------------
| (2,2),(0,0)
| (2.5,3.5),(2.5,2.5)
(2 rows)
QUERY: SELECT '' AS four, b.f1
-- area <=
SELECT '' AS four, b.f1
FROM BOX_TBL b
WHERE b.f1 <= '(3.0,3.0,5.0,5.0)'::box;
four|f1
----+-------------------
|(2,2),(0,0)
|(3,3),(1,1)
|(2.5,3.5),(2.5,2.5)
|(3,3),(3,3)
WHERE b.f1 <= box '(3.0,3.0,5.0,5.0)';
four | f1
------+---------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
(4 rows)
QUERY: SELECT '' AS two, b.f1
-- area <
SELECT '' AS two, b.f1
FROM BOX_TBL b
WHERE b.f1 < '(3.0,3.0,5.0,5.0)'::box;
two|f1
---+-------------------
|(2.5,3.5),(2.5,2.5)
|(3,3),(3,3)
WHERE b.f1 < box '(3.0,3.0,5.0,5.0)';
two | f1
-----+---------------------
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
(2 rows)
QUERY: SELECT '' AS two, b.f1
-- area =
SELECT '' AS two, b.f1
FROM BOX_TBL b
WHERE b.f1 = '(3.0,3.0,5.0,5.0)'::box;
two|f1
---+-----------
|(2,2),(0,0)
|(3,3),(1,1)
WHERE b.f1 = box '(3.0,3.0,5.0,5.0)';
two | f1
-----+-------------
| (2,2),(0,0)
| (3,3),(1,1)
(2 rows)
QUERY: SELECT '' AS two, b.f1
FROM BOX_TBL b
WHERE b.f1 > '(3.5,3.0,4.5,3.0)'::box;
two|f1
---+-----------
|(2,2),(0,0)
|(3,3),(1,1)
-- area >
SELECT '' AS two, b.f1
FROM BOX_TBL b -- zero area
WHERE b.f1 > box '(3.5,3.0,4.5,3.0)';
two | f1
-----+-------------
| (2,2),(0,0)
| (3,3),(1,1)
(2 rows)
QUERY: SELECT '' AS four, b.f1
FROM BOX_TBL b
WHERE b.f1 >= '(3.5,3.0,4.5,3.0)'::box;
four|f1
----+-------------------
|(2,2),(0,0)
|(3,3),(1,1)
|(2.5,3.5),(2.5,2.5)
|(3,3),(3,3)
-- area >=
SELECT '' AS four, b.f1
FROM BOX_TBL b -- zero area
WHERE b.f1 >= box '(3.5,3.0,4.5,3.0)';
four | f1
------+---------------------
| (2,2),(0,0)
| (3,3),(1,1)
| (2.5,3.5),(2.5,2.5)
| (3,3),(3,3)
(4 rows)
QUERY: SELECT '' AS two, b.f1
-- right of
SELECT '' AS two, b.f1
FROM BOX_TBL b
WHERE '(3.0,3.0,5.0,5.0)'::box >> b.f1;
two|f1
---+-------------------
|(2,2),(0,0)
|(2.5,3.5),(2.5,2.5)
WHERE box '(3.0,3.0,5.0,5.0)' >> b.f1;
two | f1
-----+---------------------
| (2,2),(0,0)
| (2.5,3.5),(2.5,2.5)
(2 rows)
QUERY: SELECT '' AS three, b.f1
-- contained in
SELECT '' AS three, b.f1
FROM BOX_TBL b
WHERE b.f1 @ '(0,0,3,3)'::box;
three|f1
-----+-----------
|(2,2),(0,0)
|(3,3),(1,1)
|(3,3),(3,3)
WHERE b.f1 @ box '(0,0,3,3)';
three | f1
-------+-------------
| (2,2),(0,0)
| (3,3),(1,1)
| (3,3),(3,3)
(3 rows)
QUERY: SELECT '' AS three, b.f1
-- contains
SELECT '' AS three, b.f1
FROM BOX_TBL b
WHERE '(0,0,3,3)'::box ~ b.f1;
three|f1
-----+-----------
|(2,2),(0,0)
|(3,3),(1,1)
|(3,3),(3,3)
WHERE box '(0,0,3,3)' ~ b.f1;
three | f1
-------+-------------
| (2,2),(0,0)
| (3,3),(1,1)
| (3,3),(3,3)
(3 rows)
QUERY: SELECT '' AS one, b.f1
-- box equality
SELECT '' AS one, b.f1
FROM BOX_TBL b
WHERE '(1,1,3,3)'::box ~= b.f1;
one|f1
---+-----------
|(3,3),(1,1)
WHERE box '(1,1,3,3)' ~= b.f1;
one | f1
-----+-------------
| (3,3),(1,1)
(1 row)
QUERY: SELECT '' AS four, @@(b1.f1) AS p
-- center of box, left unary operator
SELECT '' AS four, @@(b1.f1) AS p
FROM BOX_TBL b1;
four|p
----+-------
|(1,1)
|(2,2)
|(2.5,3)
|(3,3)
four | p
------+---------
| (1,1)
| (2,2)
| (2.5,3)
| (3,3)
(4 rows)
QUERY: SELECT '' AS one, b1.*, b2.*
FROM BOX_TBL b1, BOX_TBL b2
-- wholly-contained
SELECT '' AS one, b1.*, b2.*
FROM BOX_TBL b1, BOX_TBL b2
WHERE b1.f1 ~ b2.f1 and not b1.f1 ~= b2.f1;
one|f1 |f1
---+-----------+-----------
|(3,3),(1,1)|(3,3),(3,3)
one | f1 | f1
-----+-------------+-------------
| (3,3),(1,1) | (3,3),(3,3)
(1 row)
QUERY: SELECT '' AS four, height(f1), width(f1) FROM BOX_TBL;
four|height|width
----+------+-----
| 2| 2
| 2| 2
| 1| 0
| 0| 0
SELECT '' AS four, height(f1), width(f1) FROM BOX_TBL;
four | height | width
------+--------+-------
| 2 | 2
| 2 | 2
| 1 | 0
| 0 | 0
(4 rows)
QUERY: CREATE TABLE CIRCLE_TBL (f1 circle);
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(0,0),3>');
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');
QUERY: INSERT INTO CIRCLE_TBL VALUES ('1,3,5');
QUERY: INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)');
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(100,0),100>');
QUERY: INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
--
-- CIRCLE
--
CREATE TABLE CIRCLE_TBL (f1 circle);
INSERT INTO CIRCLE_TBL VALUES ('<(0,0),3>');
INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');
INSERT INTO CIRCLE_TBL VALUES ('1,3,5');
INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)');
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
INSERT INTO CIRCLE_TBL VALUES ('<(100,0),100>');
-- bad values
INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
ERROR: Bad circle external representation '<(-100,0),-100>'
QUERY: INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5');
INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5');
ERROR: Bad circle external representation '1abc,3,5'
QUERY: INSERT INTO CIRCLE_TBL VALUES ('(3,(1,2),3)');
INSERT INTO CIRCLE_TBL VALUES ('(3,(1,2),3)');
ERROR: Bad circle external representation '(3,(1,2),3)'
QUERY: SELECT * FROM CIRCLE_TBL;
f1
--------------
<(0,0),3>
<(1,2),100>
<(1,3),5>
<(1,2),3>
<(100,200),10>
<(100,0),100>
SELECT * FROM CIRCLE_TBL;
f1
----------------
<(0,0),3>
<(1,2),100>
<(1,3),5>
<(1,2),3>
<(100,200),10>
<(100,0),100>
(6 rows)
QUERY: SELECT '' AS six, center(f1) AS center
SELECT '' AS six, center(f1) AS center
FROM CIRCLE_TBL;
six|center
---+---------
|(0,0)
|(1,2)
|(1,3)
|(1,2)
|(100,200)
|(100,0)
six | center
-----+-----------
| (0,0)
| (1,2)
| (1,3)
| (1,2)
| (100,200)
| (100,0)
(6 rows)
QUERY: SELECT '' AS six, radius(f1) AS radius
SELECT '' AS six, radius(f1) AS radius
FROM CIRCLE_TBL;
six|radius
---+------
| 3
| 100
| 5
| 3
| 10
| 100
six | radius
-----+--------
| 3
| 100
| 5
| 3
| 10
| 100
(6 rows)
QUERY: SELECT '' AS six, diameter(f1) AS diameter
SELECT '' AS six, diameter(f1) AS diameter
FROM CIRCLE_TBL;
six|diameter
---+--------
| 6
| 200
| 10
| 6
| 20
| 200
six | diameter
-----+----------
| 6
| 200
| 10
| 6
| 20
| 200
(6 rows)
QUERY: SELECT '' AS two, f1 FROM CIRCLE_TBL WHERE radius(f1) < 5;
two|f1
---+---------
|<(0,0),3>
|<(1,2),3>
SELECT '' AS two, f1 FROM CIRCLE_TBL WHERE radius(f1) < 5;
two | f1
-----+-----------
| <(0,0),3>
| <(1,2),3>
(2 rows)
QUERY: SELECT '' AS four, f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10;
four|f1
----+--------------
|<(1,2),100>
|<(1,3),5>
|<(100,200),10>
|<(100,0),100>
SELECT '' AS four, f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10;
four | f1
------+----------------
| <(1,2),100>
| <(1,3),5>
| <(100,200),10>
| <(100,0),100>
(4 rows)
QUERY: SELECT '' as five, c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance
SELECT '' as five, c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance
FROM CIRCLE_TBL c1, CIRCLE_TBL c2
WHERE (c1.f1 < c2.f1) AND ((c1.f1 <-> c2.f1) > 0)
ORDER BY distance, one, two;
five|one |two | distance
----+--------------+--------------+----------------
|<(100,200),10>|<(100,0),100> | 90
|<(100,200),10>|<(1,2),100> |111.370729772479
|<(1,3),5> |<(100,200),10>|205.476756144497
|<(1,2),3> |<(100,200),10>|208.370729772479
|<(0,0),3> |<(100,200),10>|210.606797749979
five | one | two | distance
------+----------------+----------------+------------------
| <(100,200),10> | <(100,0),100> | 90
| <(100,200),10> | <(1,2),100> | 111.370729772479
| <(1,3),5> | <(100,200),10> | 205.476756144497
| <(1,2),3> | <(100,200),10> | 208.370729772479
| <(0,0),3> | <(100,200),10> | 210.606797749979
(5 rows)
QUERY: SELECT 'trailing' AS first;
first
--------
trailing
--
-- COMMENTS
--
SELECT 'trailing' AS first; -- trailing single line
first
----------
trailing
(1 row)
QUERY:
SELECT /* embedded single line */ 'embedded' AS second;
second
--------
embedded
second
----------
embedded
(1 row)
QUERY: SELECT /* both embedded and trailing single line */ 'both' AS third;
third
-----
both
SELECT /* both embedded and trailing single line */ 'both' AS third; -- trailing single line
third
-------
both
(1 row)
QUERY:
SELECT 'before multi-line' AS fourth;
fourth
-----------------
before multi-line
fourth
-------------------
before multi-line
(1 row)
QUERY: /* This is an example of SQL which should not execute:
/* This is an example of SQL which should not execute:
* select 'multi-line';
*/
SELECT 'after multi-line' AS fifth;
fifth
----------------
after multi-line
fifth
------------------
after multi-line
(1 row)
/* and this is the end of the file */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
QUERY: CREATE TABLE LSEG_TBL (s lseg);
QUERY: INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)]');
QUERY: INSERT INTO LSEG_TBL VALUES ('(0,0),(6,6)');
QUERY: INSERT INTO LSEG_TBL VALUES ('10,-10 ,-3,-4');
QUERY: INSERT INTO LSEG_TBL VALUES ('[-1e6,2e2,3e5, -4e1]');
QUERY: INSERT INTO LSEG_TBL VALUES ('(11,22,33,44)');
QUERY: INSERT INTO LSEG_TBL VALUES ('(3asdf,2 ,3,4r2)');
--
-- LSEG
-- Line segments
--
--DROP TABLE LSEG_TBL;
CREATE TABLE LSEG_TBL (s lseg);
INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)]');
INSERT INTO LSEG_TBL VALUES ('(0,0),(6,6)');
INSERT INTO LSEG_TBL VALUES ('10,-10 ,-3,-4');
INSERT INTO LSEG_TBL VALUES ('[-1e6,2e2,3e5, -4e1]');
INSERT INTO LSEG_TBL VALUES ('(11,22,33,44)');
-- bad values for parser testing
INSERT INTO LSEG_TBL VALUES ('(3asdf,2 ,3,4r2)');
ERROR: Bad lseg external representation '(3asdf,2 ,3,4r2)'
QUERY: INSERT INTO LSEG_TBL VALUES ('[1,2,3, 4');
INSERT INTO LSEG_TBL VALUES ('[1,2,3, 4');
ERROR: Bad lseg external representation '[1,2,3, 4'
QUERY: INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]');
INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]');
ERROR: Bad lseg external representation '[(,2),(3,4)]'
QUERY: INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)');
INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)');
ERROR: Bad lseg external representation '[(1,2),(3,4)'
QUERY: select * from LSEG_TBL;
s
-----------------------------
[(1,2),(3,4)]
[(0,0),(6,6)]
[(10,-10),(-3,-4)]
[(-1000000,200),(300000,-40)]
[(11,22),(33,44)]
select * from LSEG_TBL;
s
-------------------------------
[(1,2),(3,4)]
[(0,0),(6,6)]
[(10,-10),(-3,-4)]
[(-1000000,200),(300000,-40)]
[(11,22),(33,44)]
(5 rows)
QUERY: SELECT * FROM LSEG_TBL WHERE s <= '[(1,2),(3,4)]'::lseg;
s
-------------
[(1,2),(3,4)]
SELECT * FROM LSEG_TBL WHERE s <= lseg '[(1,2),(3,4)]';
s
---------------
[(1,2),(3,4)]
(1 row)
QUERY: SELECT * FROM LSEG_TBL WHERE (s <-> '[(1,2),(3,4)]'::lseg) < 10;
s
------------------
[(1,2),(3,4)]
[(0,0),(6,6)]
[(10,-10),(-3,-4)]
SELECT * FROM LSEG_TBL WHERE (s <-> lseg '[(1,2),(3,4)]') < 10;
s
--------------------
[(1,2),(3,4)]
[(0,0),(6,6)]
[(10,-10),(-3,-4)]
(3 rows)
This diff is collapsed.
QUERY: CREATE TABLE TEMP_FLOAT (f1 FLOAT8);
QUERY: INSERT INTO TEMP_FLOAT (f1)
--
-- NUMEROLOGY
-- Test various combinations of numeric types and functions.
--
--
-- Test implicit type conversions
-- This fails for Postgres v6.1 (and earlier?)
-- so let's try explicit conversions for now - tgl 97/05/07
--
CREATE TABLE TEMP_FLOAT (f1 FLOAT8);
INSERT INTO TEMP_FLOAT (f1)
SELECT float8(f1) FROM INT4_TBL;
QUERY: INSERT INTO TEMP_FLOAT (f1)
INSERT INTO TEMP_FLOAT (f1)
SELECT float8(f1) FROM INT2_TBL;
QUERY: SELECT '' AS ten, f1 FROM TEMP_FLOAT
SELECT '' AS ten, f1 FROM TEMP_FLOAT
ORDER BY f1;
ten| f1
---+-----------
|-2147483647
| -123456
| -32767
| -1234
| 0
| 0
| 1234
| 32767
| 123456
| 2147483647
ten | f1
-----+-------------
| -2147483647
| -123456
| -32767
| -1234
| 0
| 0
| 1234
| 32767
| 123456
| 2147483647
(10 rows)
QUERY: CREATE TABLE TEMP_INT4 (f1 INT4);
QUERY: INSERT INTO TEMP_INT4 (f1)
-- int4
CREATE TABLE TEMP_INT4 (f1 INT4);
INSERT INTO TEMP_INT4 (f1)
SELECT int4(f1) FROM FLOAT8_TBL
WHERE (f1 > -2147483647) AND (f1 < 2147483647);
QUERY: INSERT INTO TEMP_INT4 (f1)
INSERT INTO TEMP_INT4 (f1)
SELECT int4(f1) FROM INT2_TBL;
QUERY: SELECT '' AS nine, f1 FROM TEMP_INT4
SELECT '' AS nine, f1 FROM TEMP_INT4
ORDER BY f1;
nine| f1
----+------
|-32767
| -1234
| -1004
| -35
| 0
| 0
| 0
| 1234
| 32767
nine | f1
------+--------
| -32767
| -1234
| -1004
| -35
| 0
| 0
| 0
| 1234
| 32767
(9 rows)
QUERY: CREATE TABLE TEMP_INT2 (f1 INT2);
QUERY: INSERT INTO TEMP_INT2 (f1)
-- int2
CREATE TABLE TEMP_INT2 (f1 INT2);
INSERT INTO TEMP_INT2 (f1)
SELECT int2(f1) FROM FLOAT8_TBL
WHERE (f1 >= -32767) AND (f1 <= 32767);
QUERY: INSERT INTO TEMP_INT2 (f1)
INSERT INTO TEMP_INT2 (f1)
SELECT int2(f1) FROM INT4_TBL
WHERE (f1 >= -32767) AND (f1 <= 32767);
QUERY: SELECT '' AS five, f1 FROM TEMP_INT2
SELECT '' AS five, f1 FROM TEMP_INT2
ORDER BY f1;
five| f1
----+-----
|-1004
| -35
| 0
| 0
| 0
five | f1
------+-------
| -1004
| -35
| 0
| 0
| 0
(5 rows)
QUERY: CREATE TABLE TEMP_GROUP (f1 INT4, f2 INT4, f3 FLOAT8);
QUERY: INSERT INTO TEMP_GROUP
--
-- Group-by combinations
--
CREATE TABLE TEMP_GROUP (f1 INT4, f2 INT4, f3 FLOAT8);
INSERT INTO TEMP_GROUP
SELECT 1, (- i.f1), (- f.f1)
FROM INT4_TBL i, FLOAT8_TBL f;
QUERY: INSERT INTO TEMP_GROUP
INSERT INTO TEMP_GROUP
SELECT 2, i.f1, f.f1
FROM INT4_TBL i, FLOAT8_TBL f;
QUERY: SELECT DISTINCT f1 AS two FROM TEMP_GROUP;
two
---
1
2
SELECT DISTINCT f1 AS two FROM TEMP_GROUP;
two
-----
1
2
(2 rows)
QUERY: SELECT f1 AS two, max(f3) AS max_float, min(f3) as min_float
SELECT f1 AS two, max(f3) AS max_float, min(f3) as min_float
FROM TEMP_GROUP
GROUP BY two
ORDER BY two, max_float, min_float;
two|max_float |min_float
---+--------------------+---------------------
1|1.2345678901234e+200|0
2|0 |-1.2345678901234e+200
two | max_float | min_float
-----+----------------------+-----------------------
1 | 1.2345678901234e+200 | 0
2 | 0 | -1.2345678901234e+200
(2 rows)
QUERY: SELECT f1 AS two, max(f3) AS max_float, min(f3) AS min_float
SELECT f1 AS two, max(f3) AS max_float, min(f3) AS min_float
FROM TEMP_GROUP
GROUP BY two
ORDER BY two, max_float, min_float;
two|max_float |min_float
---+--------------------+---------------------
1|1.2345678901234e+200|0
2|0 |-1.2345678901234e+200
two | max_float | min_float
-----+----------------------+-----------------------
1 | 1.2345678901234e+200 | 0
2 | 0 | -1.2345678901234e+200
(2 rows)
QUERY: SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1
SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1
FROM TEMP_GROUP
GROUP BY two
ORDER BY two, min_minus_1;
two|max_plus_1 |min_minus_1
---+--------------------+---------------------
1|1.2345678901234e+200|-1
2|1 |-1.2345678901234e+200
two | max_plus_1 | min_minus_1
-----+----------------------+-----------------------
1 | 1.2345678901234e+200 | -1
2 | 1 | -1.2345678901234e+200
(2 rows)
QUERY: SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1
SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1
FROM TEMP_GROUP
GROUP BY two
ORDER BY two, min_minus_1;
two|max_plus_1 |min_minus_1
---+--------------------+---------------------
1|1.2345678901234e+200|-1
2|1 |-1.2345678901234e+200
two | max_plus_1 | min_minus_1
-----+----------------------+-----------------------
1 | 1.2345678901234e+200 | -1
2 | 1 | -1.2345678901234e+200
(2 rows)
QUERY: DROP TABLE TEMP_INT2;
QUERY: DROP TABLE TEMP_INT4;
QUERY: DROP TABLE TEMP_FLOAT;
QUERY: DROP TABLE TEMP_GROUP;
DROP TABLE TEMP_INT2;
DROP TABLE TEMP_INT4;
DROP TABLE TEMP_FLOAT;
DROP TABLE TEMP_GROUP;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment