Re: Incremental sum ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Incremental sum ?
Дата
Msg-id 4526.993229126@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Incremental sum ?  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
Ответы Re: Incremental sum ?  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
Список pgsql-sql
"Ross J. Reedstrom" <reedstrm@rice.edu> writes:
> And here's the working example: not the need to GROUP BY, and <=
> to get the current payment.

> select cust_id,invoice_id,val,paid, (select (sum(val) - sum(paid))
> from invoices_not_paid where cust_id= i.cust_id and invoice_id <=
> i.invoice_id group by cust_id) as balance  from invoices_not_paid i;

Actually I think you could leave off the inner GROUP BY --- won't there
always be exactly one group, since only one value of inner cust_id is
selected?
        regards, tom lane


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: cache lookup failed ???? What is it ???!!!
Следующее
От: Tom Lane
Дата:
Сообщение: Re: View performance question