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

Keith Parks <emkxp01@mtcc.demon.co.uk>

From: Keith Parks <emkxp01@mtcc.demon.co.uk>
To: pgsql-hackers@postgresql.org, rcoelho@px.com.br
Date: 1999-12-22T20:55:13Z
Lists: pgsql-hackers
"Ricardo Coelho" <rcoelho@px.com.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.