USE ap; 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;