[SQL] subselect test

2001-01-08 Thread Robert B. Easter
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

Re: Sv: [SQL] how to build this query ??? Please help !!!

2001-01-08 Thread Tom Lane
"Robert B. Easter" <[EMAIL PROTECTED]> writes: > -- this crashes > select a, (SELECT b FROM y WHERE y.b = x.a + 1) AS b > FROM x WHERE a IN (SELECT b FROM y) > GROUP BY a,b > HAVING a IN (SELECT b FROM y WHERE b > 1); Fixed. 'Twas another case of trying to close a subplan twice

[SQL] hex number

2001-01-08 Thread Jie Liang
Hi, Does anybody knows that is any function can covert an inet(IP addr) type to a hex number?? Jie LIANG Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 [EMAIL PROTECTED] www.ipinc.com

Re: Sv: [SQL] how to build this query ??? Please help !!!

2001-01-08 Thread Tom Lane
"Robert B. Easter" <[EMAIL PROTECTED]> writes: > The query I did was bad syntax I guess. No, it's just a bug. PG accepts GROUP BY items that are references to output columns, cf. http://www.postgresql.org/devel-corner/docs/postgres/sql-select.htm Looks like it gets confused when the grouped-by

Re: Sv: [SQL] how to build this query ??? Please help !!!

2001-01-08 Thread Robert B. Easter
Syntax Rules 1) Each in the shall unambiguously reference a column of the table resulting from the . A column referenced in a is a grouping column. NOTE 101 - "Column reference" is defined in Subclause 6.6, "".

Re: Sv: [SQL] how to build this query ??? Please help !!!

2001-01-08 Thread Robert B. Easter
I was playing around with subselects and managed to crash the backend (if you try, it can be done I guess): create table x (a numeric); create table y (b numeric); insert into x values (1); insert into x values (2); insert into x values (3); insert into x values (4); insert into x values (5); i

Re: [SQL] Strange Execution-Plan for NOT EXISTS

2001-01-08 Thread Tom Lane
Jens Hartwig <[EMAIL PROTECTED]> writes: > select (min(id) + 1) > from t_dummy d1 > where not exists ( > select id > from t_dummy d2 > where d2.id = (d1.id + 1) > ); > Aggregate (cost=2924207.88..2924207.88 rows=1 width=12) -> Seq Scan on t_dummy d1 (cost=0.00..2924207.88 rows=1 wid

Re: [SQL] create default

2001-01-08 Thread Jens Hartwig
Sorry, there is a "bug" in my statement (according to debug issues), the correct statement should be: CREATE FUNCTION test() RETURNS opaque AS 'BEGIN IF new.cno1 IS NULL THEN IF new.cno2 IS NULL THEN new.cno1 := trim(new.cno3); ELSIF new.cn