3- 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 in question 2) for each customer. Sort the results by customer code, and use aliases as shown below. CUS CODE CUS BALANCE| Tetal Purchases 444 00 153 05 422.77 34.97 TO 44 10011 10012 10014 600 345 86 O 00 10015 .00 10018 216 55 4- Modify the query in (question 3) 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.) The output values must match those shown in Figure below, sorted by customer code. CUS CODE CUS BALANCE Total Purchases | Number of Puurchasen 00 345 86 000 10011 10012 10014 10015 10018 444 00 163 85 422 77 3497 70 44 000 216 56 5- Use a query to compute the total of all purchases, the number of purchases, and the average purchase amount made by each customer. The output values must match those shown in Figure below. Sort the results by customer code. CUS CODE CUS BALANCE Total Purchases Number of Purchases Average Purchase Amount 74.00 51.28 70 46 17.48 10011 0.00 444.00 10012 345.86 153.85 10014 D.00 422.77 10015 0.00 216.55 34.97 2 10018 70.44 70.44
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps