Prfect! This is exactly what I needed. Didn't know postgres
supported subselects like that. Thanks.
-Michael
> select min(amtsum), max(amtsum), avg(amtsum)
> from (select sum(amount) as amtsum from payments group by userid)
> ss;
>
> In prior versions you'd need to do the initial select int
"Michael Richards" <[EMAIL PROTECTED]> writes:
> I run a select sum(amount) from payments group by userid
> I need to modify this query so it returns the minimum, maximum and
> average sums. Is there any way I can do this?
You need two levels of grouping/aggregating to make that happen.
In 7.1 y
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 mo