Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the structure and contents of the Ch 0 7 _ SaleCo database used in the class room ( also shown below ) to perform

Use the structure and contents of the Ch07_SaleCo database used in the class room (also shown below) to perform the following using MySQL:
Screenshot the Query and the Output for each Question.
A. Write a query (MySQL) to count the number of invoices.
B. Write a query to count the number of customers with a balance of more than $500.
C. Generate a listing of all purchases made by the customers, using the output shown in Figure 2 as your guide.
D. Sort the results by customer code, invoice number, and product description.
E. Using the output shown in Figure 3 as your guide, generate a list of customer purchases, including the subtotals for each of the invoice line numbers. The subtotal is a derived attribute calculated by multiplying LINE_UNITS by LINE_PRICE. Sort the output by customer code, invoice number, and product description. Be certain to use the column aliases as shown in the figure.
F. Write a query to display the customer code, balance, and total purchases for each customer. Total purchase is calculated by summing the line subtotals (as calculated in Problem D) for each customer. Sort the results by customer code, and use aliases as shown in Figure 4.
G. Modify the query in Problem E to include the number of individual product purchases made by each customer. (In other words, if the customer's invoice is based on three products, one per LINE_NUMBER, you count three product purchases. Note that in the original invoice data, customer 10011 generated three invoices, which contained a total of six lines, each representing a product purchase.) Your output values must match those shown in Figure 5, sorted by customer code.
H. Use a query to compute the total of all purchases, the number of purchases, and the average purchase amount made by each customer. Your output values must match those shown in Figure 6. Sort the results by customer code.
I. Create a query to produce the total purchase per invoice, generating the results shown in Figure 7 sorted by invoice number. The invoice total is the sum of the product purchases in the LINE that corresponds to the INVOICE.
J. Use a query to show the invoices and invoice totals in Figure 8. Sort the results by customer code and then by invoice number.
K. Write a query to produce the number of invoices and the total purchase amounts by customer, using the output shown in Figure 9 as your guide. Note the results are sorted by customer code. (Compare this summary to the results shown in Problem J Figure 8.)
L. 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. Your output must match Figure 10.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions