176k views
2 votes
Create a SELECT statement that returns the count, average, max and min of the invoices submitted by each vendor, who has submitted more than one invoice. Order by the number of invoices in descending order. Should return 12 rows.

1 Answer

3 votes

Answer:

SELECT Count(order_invoice) as number_of_invoices, Max(order_invoice) as maximum_invoice, Min(order_invoice) as minimum_invoice, Avg(order_invoice) as average_invoice

FROM vendor JOIN invoice ON invoice.id = vendor.id

WHERE order_invoice > 1

ORDER BY number_of_invoices DESC

Step-by-step explanation:

The select statement of the SQL or structured query language returns twelve rows of four columns from the inner join of the vendor and invoice table in a database where the order_invoice column in the invoice table is greater than one. The result of the query is ordered by the alias column "number_of_invoices" in descending order.

User John Sauer
by
6.1k points