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.

Database Systems: Design, Implementation, & Management
12th Edition
ISBN:9781305627482
Author:Carlos Coronel, Steven Morris
Publisher:Carlos Coronel, Steven Morris
Chapter8: Advanced Sql
Section: Chapter Questions
Problem 59P
icon
Related questions
Question
ERD:-
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_BirthYear
Transcribed Image Text:ERD:- 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_BirthYear
12. 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
0
Transcribed Image Text:12. 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 0
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Single Table
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.
Recommended textbooks for you
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781305627482
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning