My question: Why does the inner query need a table alias?
Q: Use a correlated subquery to return one row per vendor
representing the vendor's largest invoice.
Each row should include vendor_id, vendor_name, invoice_total,
and invoice_date. Order by invoice_totol in DESC.
______________________________________________________________________
SELECT v.vendor_id, vendor_name, invoice_total, invoice_date
FROM vendors v JOIN invoices i ON v.vendor_id = i.vendor_id
WHERE invoice_total = (
SELECT MAX(invoice_total) FROM invoices
WHERE vendor_id = v.vendor_id
)
ORDER BY invoice_total DESC; -- 41 vs he got 36.