Re: 7.4 Wishlist - Mailing list pgsql-hackers

From Magnus Naeslund(f)
Subject Re: 7.4 Wishlist
Date
Msg-id 06d201c29a51$4d98c040$f80c0a0a@mnd
Whole thread Raw
In response to Re: 7.4 Wishlist  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: 7.4 Wishlist
Re: 7.4 Wishlist
List pgsql-hackers
Stephan Szabo <sszabo@megazone23.bigpanda.com> wrote:
>
> If you use a scalar subquery, yes, but I think a subselect in from
> would help, maybe something like (if you want the total count)
>
> select table_name.id, sum(sum_col)||'/'||t2.count from table_name,
> (select count(*) as count from table_name) as t2 group by
> table_name.id,t2.count;
>
> or (if you want each count the counter per group) either
>
>  select id, sum(sum_col)||'/'||count(*) from table_name
> group by id;
>
> or
>
>  select table_name.id, sum(sum_col)||'/'||t2.count from table_name,
> (select id, count(*) as count from table_name group by id) as t2 where
> table_name.id=t2.id group by table_name.id,t2.count;
>

Give it up already, i was MAKING A POINT, not trying to make an
optimized count(*) thing :)
There are other examples that you cannot get around, that will be
evaluated more than once when a local "user variable" would make it not
need to.

Magnus



pgsql-hackers by date:

Previous
From: "Magnus Naeslund(f)"
Date:
Subject: Re: 7.4 Wishlist
Next
From: Rod Taylor
Date:
Subject: Re: PG 7.3: Query Meta Data with the JDBC-driver