First page Back Continue Last page Image

A Simple Summary Query Example

SELECT COUNT(*) AS number_of_invoices,

SUM(invoice_total – payment_total – credit_total)

AS total_due

FROM invoices

WHERE invoice_total – payment_total – credit_total > 0

Let’s say you want to know how many customers owe you money and how much in total your customers owe you (In Business terms: Accounts Receivable Total)

Notice there are 2 Summary Queries here, one for each question

Here is the result

Since the optional ALL or DISTINCT keywords were not used the default ALL is assumed

11 people owe you over 32 grand