154k views
1 vote
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.

User Alexandrul
by
4.7k points

1 Answer

6 votes

Answer:

See Explaination

Step-by-step 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;

User Maroodb
by
4.8k points