Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a subquery to return one row per vendor, representing the vendor’s earlies

ID: 3588270 • Letter: W

Question

Write a subquery to return one row per vendor, representing the vendor’s earliest invoice_due_date. Each row should include ( vendor name, vendor_id, count of invoices, the earliest invoice due date. Filter the result set to only show the rows with more than 3 count of invoices.

[hints:

subquery should include a group by to find invoice with the Min(invoice_due_date), and the count( invoice_id).

The major query should join with the subquery (treat the subquery as a table).

The Sub query should have alias.

All columns inside the subquery should have aliases too

Explanation / Answer

SELECT VendorName,InvoiceNumber,InvoiceDate,InvoiceTotal FROM Vendors V JOIN Invoices I ON V.VendorID=I.VendorID
WHERE InvoiceDate <= ( SELECT Min(InvoiceDate) FROM Invoices JOIN Vendors ON V.VendorID=Vendors.VendorID )
GROUP BY VendorName, InvoiceNumber, InvoiceDate, InvoiceTotal

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote