Re: finding a maximum or minimum sum
| От | Michael Richards |
|---|---|
| Тема | Re: finding a maximum or minimum sum |
| Дата | |
| Msg-id | 3B250C49.0000FD.67770@frodo.searchcanada.ca обсуждение исходный текст |
| Ответ на | finding a maximum or minimum sum ("Michael Richards" <michael@fastmail.ca>) |
| Список | pgsql-sql |
> On Mon, 11 Jun 2001, Michael Richards wrote: > >> 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? > select sum(amount),min(amount),max(amount) from payments group by > userid > > Is that what you mean? Or you want min/max _not_ to be grouped by > userid? I wanted Max $500 Min $20 Avg $276 The trouble of course is that these values are already operated upon by sum in the group. -Michael _________________________________________________________________ http://fastmail.ca/ - Fast Free Web Email for Canadians
В списке pgsql-sql по дате отправления: