176k views
1 vote
Write a SELECT statement that returns a single value that represents the sum of the largest unpaid invoices submitted by each vendor. Use a derived table that returns MAX(InvoiceTotal) grouped by VendorID, filtering for invoices with a balance due

User Pilau
by
5.3k points

1 Answer

6 votes

Answer:

Create table vendor(vendor_id int,due_invoice int,invoiceTotal int);

Create view v as select vendor_id,max(due_invoice) as unpaid from vendor;

Select sum(unpaid) from v;

Select vendor_id,invoiceTotal from vendor group by vendor_id;

User Tron
by
5.9k points