Re: [HACKERS] Non-group columns with aggregate functions - Mailing list pgsql-hackers

From Keith Parks
Subject Re: [HACKERS] Non-group columns with aggregate functions
Date
Msg-id 199912222055.UAA02650@mtcc.demon.co.uk
Whole thread Raw
List 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 |   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.



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Non-group columns with aggregate functions
Next
From: "Ricardo Coelho"
Date:
Subject: Re: [HACKERS] Non-group columns with aggregate functions