There're no another ways? It don't looks like optimal.
Petr Jezek
- Original Message -
From: "Jean-Luc Lachance" <[EMAIL PROTECTED]>
To: "Roy Souther" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, July 08, 2002 5:22 PM
Subje
That is because your query is generating a cartesian product.
Try:
SELECT (
SELECT SUM(totalprice)
FROM invoices
WHERE custnumber = '1'
) - (
SELECT SUM(paymentamount)
FROM payments
WHERE custnumber = '1'
)
Roy Souther wrote:
>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
On Sun, 7 Jul 2002, Roy Souther wrote:
> I have an invoice database that has two tables one for invoices and one for
> payments. I want to get the account balance for a client by subtracting the
> sum of all payments from the sum off all invoices for that client.
>
> Here is the SQL that I though