Question: The following script uses a derived table to return the date and invoice total of the earliest invoice issued by each vendor. Write a script
The following script uses a derived table to return the date and invoice total of the earliest invoice issued by each vendor. Write a script that generates the same result set but uses a temporary table in place of the derived table. Make sure your script tests for the existence of any objects it creates.
USE AP; SELECT VendorName, FirstInvoiceDate, InvoiceTotal FROM Invoices JOIN (SELECT VendorID, MIN(InvoiceDate) AS FirstInvoiceDate FROM Invoices GROUP BY VendorID) AS FirstInvoice ON (Invoices.VendorID = FirstInvoice.VendorID AND Invoices.InvoiceDate = FirstInvoice.FirstInvoiceDate) JOIN Vendors ON Invoices.VendorID = Vendors.VendorID ORDER BY VendorName, FirstInvoiceDate;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
