Question: In SQL 1 ) List all purchases made by customers. Your query should return the Cus _ Code, Inv _ Number, Inv _ Date, P

In SQL
1) List all purchases made by customers. Your query should return the Cus_Code, Inv_Number, Inv_Date, P_Descript, Line_Units and Line_Price. Sort by Customer code, invoice number, and product description in that order.
2) Generate a list of customer purchases, including subtotals for the invoice line numbers. Subtotals are a derived attribute, calculated by multipying Line_Units by Line_Price). Columns displayed should be Cus_Code, Inv_Number, P_Description, Units Bought (this is an alias), Unit Price (alias) and Subtotal (alias). It is up to you to determine which columns you will use to create the aliases.
3) Improve the query in question 2 by displaying Cus_LName, Cus_FName instead of Cus_Code. Use proper, modern JOIN syntax to accomplish this. Add meaningful aliases to all columns.
4) Write a query to display the Customer's Name (same format as above), the Cus_Balance and Total purchases for each customer. Total purchase amount is calculated by summing subtotals from problem 3. In other words: Find how how much the customer spent by summing the subtotals.
5) Add the number of total purchases (how many orders) to query 4. In other words, how many orders did the customer place?
6) Calculate the average purchase amount for each customer to query 5. Your column headers should be Customer Last Name, Customer First Name, Total Purchases, Number of Purchases, and Average Purchase Amount. The average purchase amount is calculated for each customer.
7) Write a query that provides the total number of invoices, the sales total for all invoices, the smallest purchase amount, largest purchase amount, and average purchase amount. You should use aliases to make your output look reasonable for a business user.
8) Advertising has requested a list of all customers who have never made a purchase, along with the customer's name and phone number. Provide them with a query with this information. Display the name in the style you believe would be most useful - briefly explain your choice in the comments.
9) Calculate the value of products currently in inventory. The value of the products can be calculated using P_QOH (quantity on hand) and P_Price. Display results with a subtotal for each different product. You should display the P_Descript, P_QOH, P_Price, and Subtotal for each product. Use aliases to improve the display.
10) Which Vendor does this company use the most frequently to supply products? Display the Vendor's name with the most products currently in the Product Table as well as the total number of products for that particular vendor. This query should display correctly if there is a tie between two vendors and if the data in the product table changes (e.g. we begin ordering more products from a particular vendor).
In SQL 1 ) List all purchases made by customers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!