"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
"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
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,
"".
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
On Thu, 4 Jan 2001, Jens Hartwig wrote:
> This would be a self-join of one table like:
>
> select ord.a_nr,
> c1.count(*),
> c2.count(*),
> ...
> from orders ord,
> cylinders c1,
> cylinders c2,
> ...
> where c1.z_a_nr = ord.a_nr
> a
Hello Tom,
> [...]
> > SELECT a, (SELECT b)
> > FROM xyz;
> [...]
> I think it's OK (we're assuming that a and b are columns of xyz, right?)
> [...]
immediately after having sent my message I realized my fault: a and b
are not of the same table! Correctly, the statement had to be something
like:
Jens Hartwig <[EMAIL PROTECTED]> 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 inn
> [...]
> Subqueries are covered in Bruce Momjian's book:
> http://www.postgresql.org/docs/aw_pgsql_book/node93.html
> [...]
Thanks for the information, but Bruce (which I have already read) and
all other docs I´ve seen "only" mention normal subselects. I know
subselects (what a poor database eng
Tod McQuillin <[EMAIL PROTECTED]> writes:
> I don't think the PostgreSQL User's Manual mentions sub-selects.
I think you are right :-(. Geez, that's a pretty big hole in the
docs coverage.
There is some stuff in the Tutorial --- see
http://www.postgresql.org/devel-corner/docs/postgres/sql-langu
On Thu, 4 Jan 2001, Jens Hartwig wrote:
> > SELECT a_nr,
> > (SELECT count(*) FROM cylinders WHERE z_a_nr = a_nr) AS #cylinder,
> > [...]
> > FROM orders
>
> Is this a documented feature? Where can I find more information about
> this? I do not want to join the actual discussion about documentat
> [...]
> SELECT a_nr,
> (SELECT count(*) FROM cylinders WHERE z_a_nr = a_nr) AS #cylinder,
> [...]
> FROM orders
> [...]
Is this a documented feature? Where can I find more information about
this? I do not want to join the actual discussion about documentation
of PostgreSQL but I never before h
Something like this oughtta work (not tested)
SELECT a_nr,
(SELECT count(*) FROM cylinders WHERE z_a_nr = a_nr) AS #cylinder,
(SELECT count(*) FROM cylinders WHERE z_a_nr = a_nr AND z_status = 'zdr') AS #zdr,
(SELECT count(*) FROM cylinders WHERE z_a_nr = a_nr AND z_status = 'zcu') AS #zcu,
(SEL
12 matches
Mail list logo