Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group