[sql] WITH Top10 AS (SELECT TOP 5 VendorID, AVG(InvoiceTotal) AS AvgInvoice FROM
ID: 3720325 • Letter: #
Question
[sql]
WITH Top10 AS
(SELECT TOP 5 VendorID, AVG(InvoiceTotal) AS AvgInvoice
FROM Invoices
GROUP BY VendorID
ORDER BY AvgInvoice DESC)
SELECT Invoices.VendorID, MAX(Invoices.InvoiceTotal) AS LargestInvoice
FROM Invoices JOIN Top10
ON Invoices.VendorID = Top10.VendorID
GROUP BY Invoices.VendorID
ORDER BY LargestInvoice DESC;
1)When this query is executed, the result table will contain one row for:
a.
each vendor
c.
each invoice
b.
each vendor in the Top10 table
d.
each invoice in the Top10 table
2)When this query is executed, each row in the result table will show
a.
the largest invoice amount related to that row
b.
the average invoice amount related to that row
c.
the largest invoice amount related to that row, but only if it’s larger than the average for all invoices
d.
the largest invoice amount related to that row, but only if it’s larger then the average for all invoices related to that row
a.
each vendor
c.
each invoice
b.
each vendor in the Top10 table
d.
each invoice in the Top10 table
Explanation / Answer
1. b. each vendor in the Top10 table
2. d. the largest invoice amount related to that row, but only if it’s larger then the average for all invoices related to that row
**Comment for any further queries.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.