Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q :List the patron id and patron first name, patron last name of the patron(s), who has(have) borrowed the most books. Use the SQL Developer

Q :List the patron id and patron first name, patron last name of the patron(s), who has(have) borrowed the most books.

Use the SQL Developer Tutorial tables:

BOOKS

PATRONS

TRANSACTIONS

If you have renamed the tables (using RENAME oldtablename TO newtablename;), your tables will be A1_BOOKS, A1_PATRONS, A1_TRANSACTIONS

books ( book_id, title, author_last_name, author_first_name, rating)

patrons (patron_id, last_name, first_name, street_address, city_state_zip, location)

transactions (transaction_id, patron_id, book_id, transaction_date, transaction_type)

Please review the Cheat sheet

Notes from Cheat Sheet: JOIN TWO TABLES also LEFT [RIGHT] OUTER JOIN

Patient (Patient_id, DOB)

Medication(Patient_id, Drug_number, Start_date, End_date)

SELECT P.Patient_id, M.Drug_number

FROM Patient P, Medication M

WHERE P.Patient_id = M.Patient_id;

- -Alternative syntax

SELECT P.Patient_id, M.Drug_number

FROM Patient P JOIN Medication M

ON P.Patient_id = M.Patient_id;

SQL AGGREGATE (GROUP) FUNCTIONS

AVG(salary) returns average value (ignores NULL values)

SUM(salary) returns sum of all salaries

MIN(column), MAX(column),

COUNT (* | [DISTINCT] columnname) returns # of rows containing a value (or distinct values) in the column

Write the following JOIN (OUTER JOIN) queries. You can also use other SQL statements, for example, UNION:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OpenStack Trove

Authors: Amrith Kumar, Douglas Shelley

1st Edition

1484212215, 9781484212219

Students also viewed these Databases questions