finding a maximum or minimum sum

Поиск
Список
Период
Сортировка
От Michael Richards
Тема finding a maximum or minimum sum
Дата
Msg-id 3B24F48D.000035.19989@frodo.searchcanada.ca
обсуждение исходный текст
Ответы Re: finding a maximum or minimum sum  (Alex Pilosov <alex@pilosoft.com>)
Re: finding a maximum or minimum sum  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
I have a table that looks like so:
userid | amount
---------------  1   |  $500  2   |  $400  2   | $-100  2   |   $10  3   |   $10  3   |   $10

I run a select sum(amount) from payments group by userid
userid | sum
-------------- 1    | $500 2    | $310 3    |  $20

I need to modify this query so it returns the minimum, maximum and 
average sums. Is there any way I can do this?

-Michael
_________________________________________________________________    http://fastmail.ca/ - Fast Free Web Email for
Canadians

В списке pgsql-sql по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Hidden Select
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: problem with Pl/Pgsql function