Create a view named Top10PaidInvoices that returns three columns for each vendor: VendorName, LastInvoice (the most recent invoice date), and SumOfInvoices (the sum of the InvoiceTotal column). Return only the 10 vendors with the largest SumOfInvoices and include only paid invoices.

Respuesta :

Answer:

See Explaination

Explanation:

SELECT TOP 10 VendorName AS Name, MAX(InvoiceDate) AS LastInvoice, SUM(InvoiceTotal) AS SumOfInvoices

FROM dbo.Vendors V JOIN dbo.Invoices I

ON V.VendorID = I.VendorID

WHERE PaymentDate IS NOT NULL

GROUP BY VendorName

ORDER BY SumOFInvoices desc;