sum of agreggates in one SELECT? - Mailing list pgsql-sql

From Louis-David Mitterrand
Subject sum of agreggates in one SELECT?
Date
Msg-id 20000919125859.A2802@styx
Whole thread Raw
Responses RE: sum of agreggates in one SELECT?
Re: sum of agreggates in one SELECT?
Re: sum of agreggates in one SELECT?
List pgsql-sql
Hello,

I have the following query/result:

auction=# select max(b.lot) as quantity,max(b.price) as price,p.login from bid b, person p where b.auction_id = 84 and
p.id= b.person_id group by p.login order by max(price);quantity | price |   login   
 
----------+-------+-----------       1 |  5000 | papy      12 |  5750 | cunctator       8 |  6000 | vindex
(3 rows)

Now I would like to sum() all results from the quantity column and
return it with one SELECT statement. Is that possible?

I am trying:

auction=# select sum(b.lot) from bid b, person p where b.auction_id = 84 and p.id = b.person_id ;sum 
----- 52
(1 row)

But this is wrong because it sums all quantities. I don't know how to
apply a valid WHERE clause in that case.

Thanks in advance for any help, cheers,


-- 
Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.org


pgsql-sql by date:

Previous
From: Jie Liang
Date:
Subject: Re: Division
Next
From: "Stuart Foster"
Date:
Subject: RE: sum of agreggates in one SELECT?