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

Поиск
Список
Период
Сортировка
От Keith Parks
Тема Re: [HACKERS] Non-group columns with aggregate functions
Дата
Msg-id 199912222055.UAA02650@mtcc.demon.co.uk
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Non-group columns with aggregate functions
Следующее
От: "Ricardo Coelho"
Дата:
Сообщение: Re: [HACKERS] Non-group columns with aggregate functions