Re: sum of agreggates in one SELECT?

Поиск
Список
Период
Сортировка
От Louis-David Mitterrand
Тема Re: sum of agreggates in one SELECT?
Дата
Msg-id 20000920084426.C1340@styx
обсуждение исходный текст
Ответ на Re: sum of agreggates in one SELECT?  (John McKown <joarmc@swbell.net>)
Список pgsql-sql
On Tue, Sep 19, 2000 at 01:17:01PM -0500, John McKown wrote:
> Well, it's not a single SELECT, but why not use something like:
> 
> SELECT MAX(b.lot) AS quanity, max(p.price) AS price, p.login
> INTO TEMPORARY TABLE temp1
> FROM bid b, person p
> WHERE b.auction_id=84 AND p.id=b.person_id
> GROUP BY p.login 
> ORDER BY max(price);
> 
> SELECT SUM(quanity) from temp1;
> 
> If you need the output from the original SELECT then you can print it by
> simply doing:
> 
> SELECT * FROM temp1;
> 
> Hope this is of some use to you,

Very useful, as it demonstrates that (as in perl) there is sometimes
more than one way to do it. Your solution works fine, and along the way
I learned to use temporary tables.

Thanks a lot for your input, cheers,

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

How's my posting?  Call 1-800-DEV-NULL


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

Предыдущее
От: Jie Liang
Дата:
Сообщение: Re: [GENERAL] Foreign Keys Help Delete!
Следующее
От: Louis-David Mitterrand
Дата:
Сообщение: Re: sum of agreggates in one SELECT?