Odd error in complex query (7.2): Sub-SELECT uses un-GROUPed...

From: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Odd error in complex query (7.2): Sub-SELECT uses un-GROUPed...
Date: 2001-10-29 03:13:02
Message-ID: 3.0.5.32.20011029141302.026c0940@mail.rhyme.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


This is using an almost up-to-date CVS version.

Sorry for the convoluted example:

Create table t1(n text, f1 int, f2 int);
create table g1(n text, t1n text);
create table s1(k1 text, f1a int, f1b int, f2 int, x int, d timestamp);

create view v1 as select k1, d,
(select g1.n from g1, t1 where g1.t1n=t1.n and t1.f1 = s1.f1a and t1.f2 =
s1.f2 limit 1) as a,
(select g1.n from g1, t1 where g1.t1n=t1.n and t1.f1 = s1.f1b and t1.f2 =
s1.f2 limit 1) as b,
x
from
s1
;

explain select coalesce(a, b, 'other') as name, k1, sum(x) as tot
from v1 where
d>'28-oct-2001 12:00' and d<current_timestamp
group by 1,2 order by tot desc limit 40;
ERROR: Sub-SELECT uses un-GROUPed attribute s1.f2 from outer query

Maybe I am asking too much of views?

----------------------------------------------------------------
Philip Warner | __---_____
Albatross Consulting Pty. Ltd. |----/ - \
(A.B.N. 75 008 659 498) | /(@) ______---_
Tel: (+61) 0500 83 82 81 | _________ \
Fax: (+61) 0500 83 82 82 | ___________ |
Http://www.rhyme.com.au | / \|
| --________--
PGP key available upon request, | /
and from pgp5.ai.mit.edu:11371 |/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Warner 2001-10-29 05:12:23 planner/optimizer question
Previous Message Mike Rogers 2001-10-29 03:05:36 Re: Ultimate DB Server