EBK DATABASE SYSTEMS: DESIGN, IMPLEMENT
12th Edition
ISBN: 8220101450739
Author: Morris
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 7, Problem 32P
Use a query to compute the average purchase amount per product made by each customer. (Hint: Use the results of Problem 31 as the basis for this query.) Your output values must match those shown in Figure P7.32. Note that the average purchase amount is equal to the total purchases divided by the number of purchases per customer.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Modify the query in Problem 13 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 P7.14, sorted by customer code.
Write a query to display the patron ID, first and last name of all patrons that have never checked out any book. Sort the result by patron last name and then first name. (See the figure below for the output)
Write a query to display the patron ID and the average number of days that patron keeps books during a checkout. Limit the results to only patrons who have at least three checkouts. Sort the results in descending order by the average days the book is kept. (See the figure below for the output)
3.) Find the goalkeepers of teams that played more than four games. List the surname of the goalkeeper, the team, and the number of minutes the goalkeeper played.
4) How many players who play on a team with ranking<10played more than 350 minutes? Return one number in a column named 'superstar'.
5) What is the average number of passes made by forwards? By midfielders? Write one query that gives both values with the corresponding position.
6) Which team has the highest average number of passes per minute played? Return the team and average passes per minute. Hints:
(1) You can compute a team's average number of passes per minute played by dividing the total number of passes by the total number of minutes. To force floating point division, multiply one operand by 1.0.
(2) Consider using Limit.
Chapter 7 Solutions
EBK DATABASE SYSTEMS: DESIGN, IMPLEMENT
Ch. 7 - Prob. 1RQCh. 7 - Explain why the following command would create an...Ch. 7 - Prob. 3RQCh. 7 - Explain why it might be more appropriate to...Ch. 7 - What is the difference between a column constraint...Ch. 7 - What are referential constraint actions?Ch. 7 - Rewrite the following WHERE clause without the use...Ch. 7 - Explain the difference between an ORDER BY clause...Ch. 7 - Explain why the following two commands produce...Ch. 7 - What is the difference between the COUNT aggregate...
Ch. 7 - Prob. 11RQCh. 7 - Prob. 12RQCh. 7 - Write the SQL code that will create the table...Ch. 7 - Having created the table structure in Problem 1,...Ch. 7 - Prob. 3PCh. 7 - Prob. 4PCh. 7 - Write the SQL code to change the job code to 501...Ch. 7 - Write the SQL code to delete the row for William...Ch. 7 - Write the SQL code that will restore the data to...Ch. 7 - Write the SQL code to create a copy of EMP_1,...Ch. 7 - Write the SQL code to change the EMP_PCT value to...Ch. 7 - Using a single command sequence, write the SQL...Ch. 7 - Prob. 11PCh. 7 - Write the SQL code that will change the PROJ_NUM...Ch. 7 - Write the two SQL command sequences required to:...Ch. 7 - Prob. 14PCh. 7 - Prob. 15PCh. 7 - Using the EMPLOYEE, JOB, and PROJECT tables in the...Ch. 7 - Write the SQL code that will produce the same...Ch. 7 - Write the SQL code to find the average bonus...Ch. 7 - Prob. 19PCh. 7 - Prob. 20PCh. 7 - Write the SQL code to calculate the ASSIGN_CHARGE...Ch. 7 - Using the data in the ASSIGNMENT table, write the...Ch. 7 - Prob. 23PCh. 7 - Write the SQL code to generate the total hours...Ch. 7 - Prob. 25PCh. 7 - Prob. 26PCh. 7 - Prob. 27PCh. 7 - Generate a listing of all purchases made by the...Ch. 7 - Using the output shown in Figure P7.29 as your...Ch. 7 - Prob. 30PCh. 7 - Prob. 31PCh. 7 - Use a query to compute the average purchase amount...Ch. 7 - Prob. 33PCh. 7 - Prob. 34PCh. 7 - Prob. 35PCh. 7 - Prob. 36PCh. 7 - Prob. 37PCh. 7 - Using the results of the query created in Problem...Ch. 7 - Create a query to find the balance characteristics...Ch. 7 - Prob. 40PCh. 7 - Prob. 41PCh. 7 - Prob. 42PCh. 7 - Prob. 43PCh. 7 - Prob. 44PCh. 7 - Write a query to display the SKU (stock keeping...Ch. 7 - Prob. 46PCh. 7 - Prob. 47PCh. 7 - Prob. 48PCh. 7 - Prob. 49PCh. 7 - Prob. 50PCh. 7 - Prob. 51PCh. 7 - Prob. 52PCh. 7 - Prob. 53PCh. 7 - Prob. 54PCh. 7 - Prob. 55PCh. 7 - Prob. 56PCh. 7 - Prob. 57PCh. 7 - Prob. 58PCh. 7 - Prob. 59PCh. 7 - Prob. 60PCh. 7 - Prob. 61PCh. 7 - Prob. 62PCh. 7 - Prob. 63PCh. 7 - Prob. 64PCh. 7 - Prob. 65PCh. 7 - Prob. 66PCh. 7 - Prob. 67PCh. 7 - Prob. 68PCh. 7 - Prob. 69PCh. 7 - Prob. 70PCh. 7 - Prob. 71PCh. 7 - Prob. 72PCh. 7 - Prob. 73PCh. 7 - Prob. 74PCh. 7 - Prob. 75PCh. 7 - Prob. 76PCh. 7 - Prob. 77PCh. 7 - Prob. 78PCh. 7 - Prob. 79PCh. 7 - Prob. 80PCh. 7 - Prob. 81PCh. 7 - Prob. 82PCh. 7 - Prob. 83PCh. 7 - Prob. 84PCh. 7 - Prob. 85PCh. 7 - Prob. 86PCh. 7 - Prob. 87PCh. 7 - Prob. 88PCh. 7 - Prob. 89PCh. 7 - Prob. 90PCh. 7 - Prob. 91PCh. 7 - Prob. 92PCh. 7 - Prob. 93PCh. 7 - Prob. 94PCh. 7 - Prob. 95PCh. 7 - Write the SQL code to create the table structures...Ch. 7 - The following tables provide a very small portion...Ch. 7 - Write the SQL command to save the rows inserted in...Ch. 7 - Write the SQL command to change the movie year for...Ch. 7 - Prob. 100CCh. 7 - Prob. 101CCh. 7 - Prob. 102CCh. 7 - Prob. 103CCh. 7 - Prob. 104CCh. 7 - Prob. 105CCh. 7 - Prob. 106CCh. 7 - Prob. 107CCh. 7 - Prob. 108CCh. 7 - Prob. 109CCh. 7 - Prob. 110CCh. 7 - Prob. 111CCh. 7 - Prob. 112CCh. 7 - Prob. 113CCh. 7 - Prob. 114CCh. 7 - Prob. 115CCh. 7 - Prob. 116CCh. 7 - Prob. 117CCh. 7 - Prob. 118CCh. 7 - Prob. 119CCh. 7 - Prob. 120CCh. 7 - Prob. 121CCh. 7 - Prob. 122CCh. 7 - Prob. 123CCh. 7 - Prob. 124CCh. 7 - Write a query to display the movie number, movie...
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.Similar questions
- Some rows of the STUDENT table are shown below: CODE NAME GPA YEAR 291 ALEX 3.1 2 938 MICHELE 2.3 1 931 JHON 3.3 1 182 JOE 3.4 2 190 REY 2.0 2 330 RON 3.9 3 Which best describes the result of the query below? SELECT YEAR, AVG(GPA) FROM STUDENT WHERE GPA > 2.0 GROUP BY YEAR a. The average maximum GPA of all the students in each year. b. The year of the student with the maximum GPA. c. The average GPA of students with a GPA higher than 2.0 each year. d. The average GPA of the students with a GPA higher than 2.0.arrow_forwardERD:- PK CHECKOUT Check Num FK1 Book_Num FK2 Pat_ID Check Out Date Check_Due Date Check_In_Date PK BOOK Book Num Book Title Book_Year Book_Cost Book_Subject FK1 Pat_ID -H- PATRON PK Pat ID Pat_FName Pat_LName Pat_Type WRITES PK,FK1 Book Num PK,FK2 Au ID AUTHOR PK AU ID Au_FName Au_LName Au_BirthYeararrow_forwardProblem 104 Write a query to display the patron ID and the average number of days that patron keeps books during a checkout. Limit the results to only patrons who have at least three checkouts. Sort the results in descending order by the average days the book is kept, and then in ascending order by patron ID (Figure P7.104). SELECT P.PAT_ID, AVG(DATEDIFF(C.CHECK_IN_DATE,C.CHECK_OUT_DATE) ) AS "AVERAGE DATE KEPT" FROM PATRON P JOIN CHECKOUT C ON P.PAT_ID=C.PAT_ID GROUP BY P.PAT_ID HAVING COUNT(C.CHECK_OUT_DATE) >= 3 Order by "AVERAGE DAYS KEPT" DESC,P.PAT_ID ASC; With the query below I am getting the wrong headers were returned, some expected rows were missing and some unexpected rows were returned. How can i correct this query to ge the expected results? Thanksarrow_forward
- Use Common Table Expressions (CTE) to write a query that displays the sum of all purchase orders and sum of all sales orders per each shipping method using the TotalDue column. All shipping methods must be displayed regardless of whether they have matching sales or purchases. Show the ShipMethodID, name, purchase orders total and sales orders total. Round all values to 2 decimal places. Hint: Use mutliple CTEs. Below is a sample of expected results:arrow_forwardQuestion 28 Write a query that displays the name and hiredate of any employee hired after 24 October 2000 and has no manager. Sort the data in the descending order of their hiredates;arrow_forwardUsing the data in the ASSIGNMENT table, write the SQL code that will yield the total number of hours worked for each employee and the total charges stemming from those hours worked, sorted by employee number. The results of running that query are shown in Figure P7.6.FIGURE P7.6 TOTAL HOURS AND CHARGES BY EMPLOYEEarrow_forward
- Some rows of the table STUDENT are shown below: CODE NAME DEPARTMENT GPA YEAR 291 ALEX PSI 3.1 1992 938 MICHELE PHY 2.3 1992 931 JHON MD 3.3 2001 182 JOE MD 3.4 2002 190 REY PHY 2.0 2001 330 RON PSI 3.9 2001 You want the name all departments that have a department GPA average of 2004 greater than the global GPA average. Which query gives you the desired result? a. SELECT DEPARTMENT FROM STUDENT WHERE YEAR = 2004 GROUP BY DEPARTMENT HAVING AVG(GPA) > (SELECT AVG(GPA) FROM STUDENT); b. SELECT DEPARTMENT FROM STUDENT WHERE YEAR = 2004 AND AVG(GPA) > (SELECT AVG(GPA) FROM STUDENT) GROUP BY DEPARTMENT; c. SELECT DEPARTMENT FROM STUDENT WHERE YEAR = 2004 GROUP BY DEPARTMENT HAVING AVG(GPA) > (SELECT GPA FROM STUDENT GROUP BY DEPARTMENT); d. SELECT * FROM STUDENT WHERE YEAR = 2004 GROUP BY DEPARTMENT HAVING AVG(GPA) > (SELECT AVG(GPA) FROM STUDENT);arrow_forwardWrite a query to display the author ID, first name, last name, and year of birth for all authors born in the decade of the 1980s sorted by author ID (Figure P7.70). In the SQL Query do the following Select clause and from clause: Display the columns specified above in the problem statement from the AUTHOR table Where clause: Only displaying information for all authors born in the decade of the 1980s. You can write this in different ways. Order by clause: sorted by author IDarrow_forwardBased on stage 2, write queries for the following questions: Write a query to display all vendors sorted by vendor name. Write a query to display the product id, description, type, base, category, and price for all products that have a product base of water and a product category of sealer. Write a query to display the first name, last name, and email address of employees who were not hired from January 1, 2015, to December 31, 2019. Sort the output by the last name and then by the first name. Write a query to display the first name, last name, phone number, title, and department number of employees who work in department 123 and have the title “Assistant.” Write a query to display the employee number, last name, first name, salary “from” date, salary end date, and salary amount for employees 99675, 53845, and 44035. Sort the output by employee number and salary “from” date. Write a query to display the first name, last name, street no, street name, city,…arrow_forward
- 8) Display the firstname, lastname of the employees and the customerID that the employee served such that the employees are born after '1960-01-01'. Arrange the results by the last name. 6) Write a SQL query to output the product name and the quantity of the Orders of that product for those orders with more than 70 quantity. (hint: don’t have to use GROUP BY) NOTE: Please use only table joining to write the SQL quereys.arrow_forwardWrite a query to display the first name, last name, and email address of employees hired from May 1, 2011, to December 31, 2012. Sort the output by last name and then by first name table 29 Write a query to display the first name, last name, phone number, title, and department number of employees who work in department 300 or have the title “CLERK I.” Sort the output by last name and then by first name, table 30 I added the tables for the questions Thank you!!arrow_forwardGiven the table customers which contains columns customer_id, first name, last name, and state, and a table named addresses that contains columns address_id, customer id, state, city, zip, and street. Write a query that returns all customers last names with their state and zip. Assume that customer id in the addresses table is foreign key referencing customer_id in the customers table.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781305627482Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781285196145Author:Steven, Steven Morris, Carlos Coronel, Carlos, Coronel, Carlos; Morris, Carlos Coronel and Steven Morris, Carlos Coronel; Steven Morris, Steven Morris; Carlos CoronelPublisher:Cengage Learning
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
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
dml in sql with examples; Author: Education 4u;https://www.youtube.com/watch?v=WvOseanUdk4;License: Standard YouTube License, CC-BY