Re: 7.4 Wishlist

Magnus Naeslund(f) <mag@fbab.net>

From: "Magnus Naeslund(f)" <mag@fbab.net>
To: "Christopher Kings-Lynne" <chriskl@familyhealth.com.au>, <pgsql-hackers@postgresql.org>
Date: 2002-12-02T20:34:20Z
Lists: pgsql-hackers, pgsql-general
Christopher Kings-Lynne <chriskl@familyhealth.com.au> wrote:
>> Mysql is planning on making this work:
>>
>>  SELECT id, @a:=COUNT(*), SUM(sum_col)/@a FROM table_name GROUP BY
>> id.
>>
>> Do we have anything like it (After a discussion with Tom i figure
>> no). User variables is nice, especially in these kind of queries.
>
> Well of course they have to make that work - they don't have
> subselects :P
>
> Chris

Yeah, but there is a point about running count(*) one time too many.
Say if i would like to get a prettyprinting query like this:

SELECT id, @a:=COUNT(*), sum_col::text||'/'@a::text FROM table_name;

That would be DAMN expensive doing with a subselect:

SELECT id, sum_col||'/'||(select COUNT(*) from tabe_name) FROM
table_name;

I know this example suck eggs, but you get the point where it hurts,
right?

Magnus - sorry for the dupe, chris