Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f049kh777608 for ; Thu, 4 Jan 2001 04:46:43 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.1/8.11.1) with ESMTP id f049kSB21125; Thu, 4 Jan 2001 04:46:28 -0500 (EST) To: Jens Hartwig cc: Tod McQuillin , Nikolaj Lundsgaard , pgsql-sql@postgresql.org Subject: Re: Sv: how to build this query ??? Please help !!! In-reply-to: <3A543766.B66B482C@debis.com> References: <3A543766.B66B482C@debis.com> Comments: In-reply-to Jens Hartwig message dated "Thu, 04 Jan 2001 09:42:14 +0100" Date: Thu, 04 Jan 2001 04:46:27 -0500 Message-ID: <21122.978601587@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200101/48 X-Sequence-Number: 709 Jens Hartwig writes: > I have never seen a statement like > SELECT a, (SELECT b) > FROM xyz; > IMHO this is no normal subselect and it does not correlate with the > SQL-standard. Is it a trick? I think it's OK (we're assuming that a and b are columns of xyz, right?) The inner select sees values from the outer select as constants. This is not really different from SELECT x FROM xyz WHERE y IN (SELECT a FROM abc WHERE b = xyz.z); where the inner WHERE relies upon an outer reference to the current xyz tuple. It is true that "SELECT b" isn't a valid SQL92 SELECT because it hasn't got a FROM clause, but that's a minor quibble that just about every vendor has invented a workaround for. regards, tom lane