Re: two sums in one query

Поиск
Список
Период
Сортировка
От PFC
Тема Re: two sums in one query
Дата
Msg-id op.stlng6uhth1vuj@localhost
обсуждение исходный текст
Ответ на Re: two sums in one query  (Bruno Wolff III <bruno@wolff.to>)
Ответы Re: two sums in one query  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-sql
>> SELECT (SELECT sum(amount) FROM table WHERE debit=X) AS debit, (SELECT
>> sum(amount) FROM table WHERE credit=x) AS credit;
>
> If most of the records are credits or debits you don't want to do this.
> A single sequential scan through the table will be the best plan.
I thought that debit = source account # and credit = dest account #, and  
there are a lot of different account...




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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Make COUNT(*) Faster?
Следующее
От: Steve Wampler
Дата:
Сообщение: Re: Make COUNT(*) Faster?