subselect test

From: "Robert B(dot) Easter" <reaster(at)comptechnews(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: subselect test
Date: 2001-01-09 07:06:30
Message-ID: 0101090206301S.09559@comptechnews
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

SELECT a, (SELECT b FROM y LEFT JOIN n ON b = c WHERE b = a + 1) AS b, c FROM
(SELECT * FROM y CROSS JOIN (x NATURAL RIGHT JOIN n)) AS z NATURAL JOIN
(SELECT * FROM x) AS zz WHERE a NOT IN (SELECT b FROM y NATURAL JOIN x WHERE
b > 5) GROUP BY a, b, c HAVING a IN (SELECT b FROM y LEFT JOIN x ON (a = b)
CROSS JOIN n WHERE b > 1) INTERSECT SELECT * FROM x,y,n EXCEPT SELECT * FROM
x,y,n WHERE a < 3 ORDER BY a DESC LIMIT 10;

a | b | c
----------+----------+----------
5.000000 | 6.000000 | 1.000000
5.000000 | 6.000000 | 2.000000
5.000000 | 6.000000 | 3.000000
5.000000 | 6.000000 | 4.000000
5.000000 | 6.000000 | 5.000000
5.000000 | 6.000000 | 6.000000
5.000000 | 6.000000 | 7.000000
4.000000 | 5.000000 | 1.000000
4.000000 | 5.000000 | 2.000000
4.000000 | 5.000000 | 3.000000
(10 rows)

Is this confusing? Is the result correct? Anyway, these new complex queries
seem to be doing something in 7.1 cvs!

--
-------- Robert B. Easter reaster(at)comptechnews(dot)com ---------
-- CompTechNews Message Board http://www.comptechnews.com/ --
-- CompTechServ Tech Services http://www.comptechserv.com/ --
---------- http://www.comptechnews.com/~reaster/ ------------

Browse pgsql-sql by date

  From Date Subject
Next Message Kaare Rasmussen 2001-01-09 09:49:45 PostgreSQL web page
Previous Message Tom Lane 2001-01-09 04:09:14 Re: Sv: how to build this query ??? Please help !!!