Re: Sv: how to build this query ??? Please help !!! - Mailing list pgsql-sql

From Tom Lane
Subject Re: Sv: how to build this query ??? Please help !!!
Date
Msg-id 21122.978601587@sss.pgh.pa.us
Whole thread Raw
In response to Re: Sv: how to build this query ??? Please help !!!  (Jens Hartwig <jhartwig@debis.com>)
List pgsql-sql
Jens Hartwig <jhartwig@debis.com> 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


pgsql-sql by date:

Previous
From: Jens Hartwig
Date:
Subject: Re: Sv: how to build this query ??? Please help !!!
Next
From: Jens Hartwig
Date:
Subject: Re: Sv: how to build this query ??? Please help !!!