Use a correlated subquery to return one row per vendor, representing the vendor’s oldest invoice (the one with the earliest date) that is due within the next 2 weeks.
Each row should include these five columns:
| vendor_name | invoice_number | invoice_date | invoice_due_date | invoice_total |
|---|
This is what I have so far just stuck in how I do the invoice_due_date:
SELECT vendor_name, invoice_number, invoice_date, invoice_total
FROM vendors v JOIN invoices i
WHERE invoice_date <= ( SELECT Min(invoice_date)
FROM invoices JOIN vendors ON v.vendor_id = v.vendor_id )
GROUP BY vendor_name, invoice_number, invoice_date, invoice_total;