Question: Consider the following code example: SELECT i . vendor _ id , MAX ( i . invoice _ total ) AS largest _ invoice FROM
Consider the following code example:
SELECT ivendorid MAXiinvoicetotal AS largestinvoice
FROM invoices i
JOIN
SELECT vendorid AVGinvoicetotal AS averageinvoice
FROM invoices
GROUP BY vendorid
HAVING AVGinvoicetotal ia
ON ivendorid iavendorid
GROUP BY ivendorid
ORDER BY largestinvoice DESC
When this query is executed, each row in the result table will show
Consider the following code example:
SELECT ivendorid MAXiinvoicetotal AS largestinvoice
FROM invoices i
JOIN
SELECT vendorid AVGinvoicetotal AS averageinvoice
FROM invoices
GROUP BY vendorid
HAVING AVGinvoicetotal ia
ON ivendorid iavendorid
GROUP BY ivendorid
ORDER BY largestinvoice DESC
When this query is executed, each row in the result table will show
the largest invoice total related to that row
the average invoice total related to that row
the largest invoice total related to that row, but only if its larger than the average for all invoices
the average invoice total related to that row, but only if its greater than
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
