Q1: Specify The Following Queries On The Database of Figure (1) Bellow in SQL
Q1: Specify The Following Queries On The Database of Figure (1) Bellow in SQL
GHADIR AL JARO
Q1: Specify the following queries on the database of Figure (1) bellow in SQL:
Figure 1
a. How many copies of the book titled The Lost Tribe are owned by the library branch whose name is
'Sharpstown'?
SELECT NoOfCopies
b. How many copies of the book titled The Lost Tribe are owned by each library branch?
c. Retrieve the names of all borrowers who do not have any books checked out.
SELECT Name
FROM BORROWER B
FROM BOOK_LOANS L
d. For each book that is loaned out from the 'Sharpstown' branch and whose DueDate is today,
retrieve the book title, the borrower's name, and the borrower's address.
e. For each library branch, retrieve the branch name and the total number of books loaned out
GROUP BY L.BranchName
DataBase Discussion ENG. GHADIR AL JARO
f. Retrieve the names, addresses, and number of books checked out for all borrowers who have
GROUP BY B.CardNo
g. For each book authored (or coauthored) by 'Stephen King,' retrieve the title and the number of
copies owned by the library branch whose name is 'Central.'
Q2: Specify the following queries on the database of Figure (2) bellow in SQL:
Figure 2
DataBase Discussion ENG. GHADIR AL JARO
a. Retrieve the names of all senior students majoring in 'COSC' (computer science).
SELECT Name
FROM STUDENT
WHERE Major='COSC'
b. Retrieve the names of all courses taught by professor King in 85 and 86.
SELECT CourseName
SELECT CourseName
FROM COURSE
FROM SECTION
c. For each section taught by professor King, retrieve the course number, semester, year, and number
of students who took the section.
d. Retrieve the name and transcript of each senior student (Class=5) majoring in COSC. Transcript
includes course name, course number, credit hours, semester, year, and grade for each course
completed by the student.
e. Retrieve the names and major departments of all straight A students (students who have a grade
of A in all their courses).
FROM STUDENT
FROM GRADE_REPORT
f. Retrieve the names and major departments of all students who do not have any grade of A in any
of their courses.
FROM STUDENT
FROM GRADE_REPORT