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 29P
Using the output shown in Figure P7.29 as your guide, generate a list of customer purchases, including the subtotals for each of the invoice line numbers. (Hint: Modify the query format used to produce the list of customer purchases in Problem 28, delete the INV_DATE column, and add the derived attribute LINE_UNITS * LINE_PRICE to calculate the subtotals.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
CUSTOMER
Customer table is composed of customer number, name and phone number.
Give and fill-in the appropriate attribute name for each of the column.
custID
123
124
125
126
reservelD
5001
5002
5003
5004
5005
5006
5007
RESERVATION
Each reservation is for one taxi. Reservation table is composed of reservation identification number, start
reservation date, end reservation date, reservation days requested by customers starting from reservation
date until end of reservation date, customer number that make the reservation and taxi number assigned
to the reservation.
Give and fill-in the appropriate attribute name for each of the column.
taxill
custName
Ahmad Bin Abdullah
Fatimah Binti Adam
LAI
LA2
Ruqayya Binti Idris
Sulaiman Bin Daud
LA3
LA4
startDate
01/10/2019
05/10/2019
05/10/2019
15/10/2019
20/10/2019
27/10/2019
02/11/2019
taxiType
endDate
03/10/2019
12/10/2019
08/10/2019
17/10/2019
25/10/2019
Sedan
Sedan
Van
Van
30/10/2019
04/11/2019
cust Phoneno
TAXI
Taxi table is composed of taxi…
Problem 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? Thanks
List unique first (first_name) and last names (last_name) of customers (CUSTOMER table) who rented a movie (RENTAL table) between '2011-06-01' and '2012-01-01’ (rental_date). Sort by last_name. The common key is CUSTOMER_ID.
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
- Insert into table customerPayment, columns customerOrderld and total result set returned from query a. Select columns id and total from table customerOrder where column orderStateld is equal to subquery i. (select column id from table orderState where column state is equal to "Payment received") Write Test Case 1 as a SQL join query to do the following a. Select using concatenation of columns firstName and lastName from table www customer as Customer b. Select customerOrderId from table customerPayment as "Customer Order" c. Select description from table product as Product d. Select total from table customerOrder as “Product Total" e. Join tables customerPavment, customerOrder, customer, product f. Order by column lastName from table customer Alter table purchaseOrder add column total as data type decimal size 7,2, not null, default value of 0.0arrow_forwardUsing the tables below Now create a query, which will show the equipment rented out with status. You should include all columns relevant to this query context. (You have to decide). CREATE TABLE equipment{equipmentId int,equipmentDesc varchar(50),equipmentPrice decimal(8,2),Primary key(equipmentId, equipmentPrice));CREATE TABLE rental(Rentalid int,RentalDate date,equipmentId int,equipmentPrice decimal(8,2),Status char(1)Primary key(Rentalid, RentalDate),Foreign key(equipmentId, equipmentPrice) references equipment(equipmentID, equipmentPrice));arrow_forwardFrom invoices table, write a query to retrieve everything (all columns), plus, add an additional column that retrieves difference in the number of days between the invoice due date and paymentdate, and name the column “Difference”. Note that the difference in days should be calculated bysubtracting “payment_date” from “invoice_due_date”.Hint1, refer to the following sample:... Invoice Due Date Payment Date Difference... 2018-05-08 2018-05-07 1... 2018-05-10 2018-05-14 -4... 2018-05-13 2018-05-09 4Hint 2: simple subtraction or DATEDIFF function. Both works.arrow_forward
- 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)arrow_forwardFill in the blanks('x') of this nested query to show the countries in EUROPE with a per capita GDP greater than UNITED KINGDOM. Table structure: world(name, gdp, population, continent) SELECT name FROM world x1gdp/ population > ( SELECT gdp/population FROM world x2x3x4'UNITED KINGDOM'x5 x6continent x7'EUROPE';arrow_forwardUpdate table purchaseOrder, set column orderStateld equal to subquery a. (select column id from table orderstate where state equals "Payment sent") 3 Alter table supplierTransaction add column paymentDate as data type date, not null, default value of (CURRENT_DATE) (Note: the parenthesis MUST be included) Insert into table supplierTransaction, columns purchaseOrderId and total result set returned from query a. Select columns id and total from table purchaseOrder where column orderStateld is equal to subquery i. (select column id from table orderState where column state is equal to "Payment sent") Write Test Case 2 as a SQL join query to do the following a. Select supplierName from table supplier as Supplier b. Select purchaseOrderld from table supplierTransaction as “Purchase Order" c. Select description from table product as Product d. Select total from table purchaseOrder as “Product Total" e. Join tables şupplierTransaction, purchaseOrder, supplier, product f. Order by column…arrow_forward
- All the queries should be executed in MySQL and Screen Shot has to be attached for each question.arrow_forwardCreate a NONCAT table with the structure shown in Figure 6-28. Insert into the NONCAT table the item ID, description, number of units on hand, category, and unit price from the ITEM table for each item that is not in category CAT. In the NONCAT table, change the description of item ID DT12 to “Dog Toy Gift Bonanza.”arrow_forwardUse multiple-row subquery in a WHERE clause. List order numbers of books, written by an author whose author ID is J100, that were ordered by the customers. Include the following columns in the result. a. Order Numberb. ISBNc. QuantityHint: In this task, we will compare the list of books in the subquery with the list of books in the outer query. The subquery returns ISBN of books that were written by the author J100. The outer query returns all order records (each record contains order number, ISBN, and quantity)arrow_forward
- 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.arrow_forwardConsider the "Employee" table which contains five columns: "Id", "Name", "Salary", "Designation and "Experience" in the format given below. Write a query to display the sum of the salary of the employees corresponding to their names. Multiple employees with the same name should be displayed only once in the output. 11 Employee Column ld Type Int(10) Varchar(20) Int(20) 12 Name Salary DesignationVarchar(20) ExpinYears DECIMAL(3, 2) 13 14 Sample Input: 15 Employee Salary Designation Experience System Engg System Engg Manager Lead IT Analyst Id Name 16 101 Rajesh 13000 3 102 Pritam 5000 17 104 105 106 103 107 Ramesh John Prttam John Vicky 40000 30000 20000 10000 80000 10 15 18 10 Lead 19 Lead 20 Sample Qutnut John 40000 Pritam 25000 20 Next Question 04: 18 A E E l * O 0 A C ENG 11:47 PM 25-03-2022 DOLL SHOT ON REDMI 7 AI DUAL CAMERA F10 F11 F12arrow_forward12. Write a query to display the patron ID, book number, and days kept for each check-out. "Days Kept" is the difference from the date on which the book is returned to the date it was checked out. Sort the results by days kept in descending order, then by patron ID, and then by book number. PATRON BOOK Days Kept 1165 5235 9 1209 5238 1160 5240 1160 5237 1202 5236 1203 5235 1174 5244 1181 5248 1170 5242 1161 5235 59 9 3 30000 8 8 3 1 4 0arrow_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 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 LearningNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
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
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
dml in sql with examples; Author: Education 4u;https://www.youtube.com/watch?v=WvOseanUdk4;License: Standard YouTube License, CC-BY