When this query is executed, the rows will be sorted by SELE…
When this query is executed, the rows will be sorted by SELECT vendor_name, COUNT(*) AS number_of_invoices, MAX(invoice_total – payment_total – credit_total) AS balance_dueFROM 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_nameORDER BY number_of_invoices, balance_due DESC;