0% found this document useful (0 votes)
49 views9 pages

Patel Task1 SQL Result

The document contains 10 SQL queries and their answers. The queries retrieve information from various tables in a university database like courses taught by an instructor, class schedules, instructor details, student majors and statuses. The answers use joins, where clauses and aggregate functions to display the relevant data.

Uploaded by

huma tariq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views9 pages

Patel Task1 SQL Result

The document contains 10 SQL queries and their answers. The queries retrieve information from various tables in a university database like courses taught by an instructor, class schedules, instructor details, student majors and statuses. The answers use joins, where clauses and aggregate functions to display the relevant data.

Uploaded by

huma tariq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Query # 1

Write SQL statement to display the course numbers of classes taught by


Hammett Glenn.

Answer:

Select Course_No from CLASS JOIN INSTRUCTOR ON


CLASS.Instructor_Id=INSTRUCTOR.Instructor_Id where
INSTRUCTOR.First_Name="Hammett" and INSTRUCTOR.Last_Name="Glenn"

Image 1:
Query # 2

Write a SQL statement to display the course names of the courses


taught by an instructor whose id is 415.

Answer:

Select Course_Name from COURSE JOIN APPROVED_INSTRUCTOR ON


COURSE.Course_No=APPROVED_INSTRUCTOR.Course_No where
APPROVED_INSTRUCTOR.Instructor_Id="415"

Image 2:

Q3: Write a query to display the name and office number of all instructors who teach Psy101.
(USE NATURAL JOIN)

A3: select FIRST_NAME, LAST_NAME,OFFICE_NO from INSTRUCTOR NATURAL JOIN


COURSE where COURSE.Course_Name="Psy101"

Image 3:
Q4: Write a query to display the semester and the number of courses offered in that semester.
Display only the semesters that offer more than five courses.

A4: select Semester,Course_No from CLASS where Semester>"5"

Image 4_1:
Image 4_2:

Q5: Write a SQL statement to display the name of each campus and the total number of rooms in
that campus.

A5: SELECT CAMPUS.Campus_Name,ROOM.ROOM_NO from CAMPUS INNER JOIN ROOM ON


CAMPUS.Campus_Name=ROOM.Campus_Name

Image 5_1:
Image 5_2:

Q7: Write a SQL statement to display the start date and start time of all classes taught by
instructor Hammett Glenn.

A7: select Start_Date,Start_Time from CLASS JOIN INSTRUCTOR ON


CLASS.Instructor_Id=INSTRUCTOR.Instructor_Id where INSTRUCTOR.First_Name="Hammett" and
INSTRUCTOR.Last_Name="Glenn"

Image 7:
Q8: Write a SQL statement to display the number of students in each major with a status of
failing.

A8: select STUDENT.MAJOR,STUDENT.STATUS,COUNT(Student_Id) as student_no from STUDENT


where STUDENT.STATUS="FAILING"

Image8:
Q9: Write a SQL statement to display the credit hours of all courses that Hammett Glenn is
approved to teach.

A9: select COURSE.CreditHours from COURSEINNER JOIN APPROVED_INSTRUCTOR ON


COURSE.Course_No= APPROVED_INSTRUCTOR.Course_No where
APPROVED_INSTRUCTOR.Instructor_Id=415

Image9:
Q10: Get the campus name and phone number of all rooms with numbers greater than 25.

A10: SELECT ROOM.Campus_Name,ROOM.ROOM_NO,CAMPUS.PHONE_NO FROM CAMPUS INNER


JOIN ROOM ON CAMPUS.Campus_Name=ROOM.Campus_Name WHERE ROOM.ROOM_NO >25
Image10:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy