Re: sub-select with aggregate - Mailing list pgsql-sql

From Tomasz Myrta
Subject Re: sub-select with aggregate
Date
Msg-id 3DB6AC12.3030506@klaster.net
Whole thread Raw
In response to Re: sub-select with aggregate  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: sub-select with aggregate
List 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 by date:

Previous
From: Tomasz Myrta
Date:
Subject: Re: 7.2 time format funtion issue
Next
From: "Carlos Sousa"
Date:
Subject: problem with a query