pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomasz Myrta <jasiek@klaster.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: order by and aggregate
Date: Mon, 06 Jan 2003 18:07:57 +0100
Message-ID: <3E19B7ED.4020901@klaster.net> (raw)
In-Reply-To: <3E197A39.8070808@klaster.net>
References: <3E197A39.8070808@klaster.net>
	<14734.1041870875@sss.pgh.pa.us>

Tom Lane wrote:

> I don't understand what you think is wrong with this solution.  It works
> fine for me:
>
> regression=# create view vv as
> regression-# select max(unique1) from (select unique1 from tenk1
> regression(# order by unique2) x;
> CREATE VIEW
> regression=# explain select * from vv;
>                                             QUERY PLAN
>
> ---------------------------------------------------------------------------------------------------
>  Subquery Scan vv  (cost=523.00..523.00 rows=1 width=8)
>    ->  Aggregate  (cost=523.00..523.00 rows=1 width=8)
>          ->  Subquery Scan x  (cost=0.00..498.00 rows=10000 width=8)
>                ->  Index Scan using tenk1_unique2 on tenk1 
> (cost=0.00..498.00 rows=10000 width=8)
> (4 rows)
>
OK, your view is ok.

I think, you don't remember my questions about "joining views" and 
"sub-select with aggregate" dated on 2002-10-23, so I qoute your answer 
on that question (joining views):
 >I think this is the same issue that Stephan identified in his response
 >to your other posting ("sub-select with aggregate").  When you write
 >	FROM x join y using (col) WHERE x.col = const
 >the WHERE-restriction is only applied to x.  I'm afraid you'll need
 >to write
 >	FROM x join y using (col) WHERE x.col = const AND y.col = const
 >Ideally you should be able to write just
 >	FROM x join y using (col) WHERE col = const
 >but I think that will be taken the same as "x.col = const" :-(

I have the same problem here, query is a bit complicated and has 
some_table join (subselect) X using (some_field) which doesn't work.

Regards,
Tomasz Myrta





view thread (9+ messages)

Message-ID: <3E19B7ED.4020901@klaster.net>
Permalink:  ../3E19B7ED.4020901@klaster.net/
Also on:    postgresql.org/message-id/3E19B7ED.4020901@klaster.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jasiek@klaster.net, tgl@sss.pgh.pa.us
  Subject: Re: order by and aggregate
  In-Reply-To: <3E19B7ED.4020901@klaster.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox