From: | Tomasz Myrta <jasiek(at)klaster(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: order by and aggregate |
Date: | 2003-01-06 17:07:57 |
Message-ID: | 3E19B7ED.4020901@klaster.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Gary Stainburn | 2003-01-06 17:29:07 | sub-select, view and sum() |
Previous Message | Tomasz Myrta | 2003-01-06 16:59:54 | Re: order by and aggregate |