Re: two sums in one query - Mailing list pgsql-sql

From PFC
Subject Re: two sums in one query
Date
Msg-id op.stlng6uhth1vuj@localhost
Whole thread Raw
In response to Re: two sums in one query  (Bruno Wolff III <bruno@wolff.to>)
Responses Re: two sums in one query
List 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 by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Make COUNT(*) Faster?
Next
From: Steve Wampler
Date:
Subject: Re: Make COUNT(*) Faster?