"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 | 9YOU | 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.