Re: order by and aggregate
От | Tomasz Myrta |
---|---|
Тема | Re: order by and aggregate |
Дата | |
Msg-id | 3E19B7ED.4020901@klaster.net обсуждение исходный текст |
Ответ на | order by and aggregate (Tomasz Myrta <jasiek@klaster.net>) |
Список | 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-restrictionis only applied to x. I'm afraid you'll need>to write> FROM x join y using (col) WHERE x.col = constAND y.col = const>Ideally you should be able to write just> FROM x join y using (col) WHERE col = const>but I thinkthat 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
В списке pgsql-sql по дате отправления: