Re: [HACKERS] Non-group columns with aggregate functions

From: Keith Parks <emkxp01(at)mtcc(dot)demon(dot)co(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org, rcoelho(at)px(dot)com(dot)br
Subject: Re: [HACKERS] Non-group columns with aggregate functions
Date: 1999-12-22 20:55:13
Message-ID: 199912222055.UAA02650@mtcc.demon.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Ricardo Coelho" <rcoelho(at)px(dot)com(dot)br>
>
>How can I use non-group columns in a select with aggregate functions ? To
>me, the following query makes sense.
>

<snip>

>teste=> select pp_name,wp_date,sum(hoursofwork) from people,workpgsql
>teste-> where pp_id=wp_people
>teste-> group by wp_people,wp_date;
>ERROR: Illegal use of aggregates or non-group column in target list
>
>If anybody knows how to rebuild this query to work, thanks in advance.
>

Maybe one of these?

postgres=# select pp_name,wp_date,sum(hoursofwork) from people,workpgsql where
pp_id=wp_people group by pp_name,wp_date;
pp_name | wp_date | sum
---------+------------+-----
ME | 01-01-2000 | 9
YOU | 01-01-2000 | 12
(2 rows)

postgres=# select wp_people,wp_date,sum(hoursofwork) from people,workpgsql where
pp_id=wp_people group by wp_people,wp_date;
wp_people | wp_date | sum
-----------+------------+-----
1 | 01-01-2000 | 9
2 | 01-01-2000 | 12
(2 rows)

Keith.

Browse pgsql-hackers by date

  From Date Subject
Next Message Karel Zak - Zakkr 1999-12-23 15:20:23 empty concatenate
Previous Message Ricardo Coelho 1999-12-22 20:48:56 Re: [HACKERS] Non-group columns with aggregate functions