8- Write a query to generate the total number of invoices, the invoice total for all of the invoices, the smallest of the customer purchase amounts, the largest of the customer purchase amounts, and the average of all the customer purchase amounts. The output must match Figure below. Total Invoices Total Sales Minimum Customer Purchases Largest Customer Purchases Average Customer Purchases 8 1126.03 34.97 444.00 225.21
8- Write a query to generate the total number of invoices, the invoice total for all of the invoices, the smallest of the customer purchase amounts, the largest of the customer purchase amounts, and the average of all the customer purchase amounts. The output must match Figure below. Total Invoices Total Sales Minimum Customer Purchases Largest Customer Purchases Average Customer Purchases 8 1126.03 34.97 444.00 225.21
Chapter11: Group Functions
Section: Chapter Questions
Problem 16MC
Related questions
Question
SELECT COUNT(INV_NUMBER) AS 'Total Invoices', SUM(TOTAL_PRICE) AS 'Total Sales', MIN(TOTAL_PRICE) AS 'Minimum Customer Purchases', MAX(TOTAL_PRICE) AS 'Largest Customer Purchases', ROUND(AVG(TOTAL_PRICE), 2) AS 'Average Customer Purchases'
FROM (SELECT CUS_CODE, LINE.INV_NUMBER AS INV_NUMBER, ROUND(SUM(LINE.LINE_PRICE * LINE.LINE_UNITS), 2) AS TOTAL_PRICE
FROM INVOICE, LINE
WHERE INVOICE.INV_NUMBER = LINE.INV_NUMBER
GROUP BY CUS_CODE, LINE.INV_NUMBER
ORDER BY CUS_CODE, LINE.INV_NUMBER)
INVOICELINE;
i use this code but it didn't show the same value as in the question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781285196145
Author:
Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781285196145
Author:
Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos Coronel
Publisher:
Cengage Learning
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
A Guide to SQL
Computer Science
ISBN:
9781111527273
Author:
Philip J. Pratt
Publisher:
Course Technology Ptr