Code example 6-1
--------------------------------------------------------
SELECT vendor_name, COUNT(*) AS number_of_invoices,
MAX(invoice_total - payment_total - credit_total) AS balance_due
FROM vendors v
JOIN invoices i
ON v.vendor_id = i.vendor_id
WHERE invoice_total - payment_total - credit_total >
(SELECT AVG(invoice_total - payment_total - credit_total)
FROM invoices)
GROUP BY vendor_name
ORDER BY balance_due DESC
--------------------------------------------------------
(Please refer to code example 6-1.) When this query is executed, the result set will contain
===================================================
A) one row for each invoice that has a larger balance due than the average balance due for all invoices
B) one row for each vendor that shows the largest balance due for any of the vendor's invoices, but only if that balance due is larger than the average balance due for all invoices
C) one row for the invoice with the largest balance due for each vendor
D) one row for each invoice for each vendor that has a larger balance due than the average balance due for all invoices