Re: sub-select with aggregate

Поиск
Список
Период
Сортировка
От Tomasz Myrta
Тема Re: sub-select with aggregate
Дата
Msg-id 3DB6AC12.3030506@klaster.net
обсуждение исходный текст
Ответ на Re: sub-select with aggregate  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Ответы Re: sub-select with aggregate
Список pgsql-sql
Uz.ytkownik Stephan Szabo napisa?:
> Does using X.group_id=3 in the where clause work better?
It works better, but not if you want to create a view and make
"select * from some_view where group_id=3" :-(
> 
> On 7.3 with no statistics for the table, that appears
> to move the filter into the subquery plan rather than the
> outer users scan.
Do you mean the second query will work on 7.3?
select  group_id,  user_id,  a/sum_a as percent_a,  b/sum_b as percent_b
from  users U,  (select    sum(a) as sum_a,    sum(b) as sum_b   from users where group_id=U.group_id) X
where group_id=3;

Tomasz Myrta



В списке pgsql-sql по дате отправления:

Предыдущее
От: Tomasz Myrta
Дата:
Сообщение: Re: 7.2 time format funtion issue
Следующее
От: "Carlos Sousa"
Дата:
Сообщение: problem with a query