Question: SELECT vendor _ name, COUNT ( * ) AS number _ of _ invoices, MAX ( invoice _ total - payment _ total - credit
SELECT vendorname, COUNT AS numberofinvoices,
MAXinvoicetotal paymenttotal credittotal AS balancedue
FROM vendors v
JOIN invoices i
ON vvendorid ivendorid
WHERE invoicetotal paymenttotal credittotal
SELECT AVGinvoicetotal paymenttotal credittotal
FROM invoices
GROUP BY vendorname
ORDER BY balancedue DESC
When this query is executed, the numberofinvoices for each row will show the number
Consider the following code example:
SELECT vendorname, COUNT AS numberofinvoices,
MAXinvoicetotal paymenttotal credittotal AS balancedue
FROM vendors v
JOIN invoices i
ON vvendorid ivendorid
WHERE invoicetotal paymenttotal credittotal
SELECT AVGinvoicetotal paymenttotal credittotal
FROM invoices
GROUP BY vendorname
ORDER BY balancedue DESC
When this query is executed, the numberofinvoices for each row will show the number
of invoices for each vendor that has a larger balance due than the average balance due for all invoices
of invoices in the Invoices table
of invoices for each vendor
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
