0% found this document useful (0 votes)
67 views3 pages

SQL Model Answer

The document contains 9 SQL queries that retrieve information from various database tables related to students, courses, and professors: 1. Finds the names and GPAs of students with a major of "IS". 2. Finds the textbook used for the mathematics course. 3. Lists student names sorted by major and then GPA within each major. 4. Finds the student identification numbers of students who attended course "CS-123". 5. Finds the names of students who attended course "CS-123". 6. Finds the names of students who attended the mathematics course. 7. Finds the names of students who attended a course taught by professor "P10". 8. Finds the names of students

Uploaded by

Amr Ali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views3 pages

SQL Model Answer

The document contains 9 SQL queries that retrieve information from various database tables related to students, courses, and professors: 1. Finds the names and GPAs of students with a major of "IS". 2. Finds the textbook used for the mathematics course. 3. Lists student names sorted by major and then GPA within each major. 4. Finds the student identification numbers of students who attended course "CS-123". 5. Finds the names of students who attended course "CS-123". 6. Finds the names of students who attended the mathematics course. 7. Finds the names of students who attended a course taught by professor "P10". 8. Finds the names of students

Uploaded by

Amr Ali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

STUDENT PROF COURSE ST-CRS PROF-CRS

S-Id P-Id Cno Sno Pno


Sname Pname Cname Cno Cno
Major Dept Txt-book Grade
GPA

1) Find names and GPAs for Information Systems Students

SELECT Sname, GPA


FROM STUDENT
WHERE Major =’IS’

2) Find the text-book used by the mathematics course

SELECT Txt-book
FROM COURSE
WHERE Cname =’mathematics’

3) List Student names sorted by their majors and within each


major sort Students by their GPAs

SELECT Sname, Major, GPA


FROM STUDENT
Order by Major, GPA

4) Find identification numbers for Students who have attend Course number “CS-
123”

SELECT Sno
FROM ST-CRS
WHERE C-no =’CS-123’

5) Find names of Students who attend Course number “CS-123”

SELECT Sname
FROM STUDENT, ST-CRS
WHERE C-no =’CS-123’
and
STUDENT.S_id =ST-CRS.Sno

1
6) Find names of Students who have attend the mathematics Course

SELECT Sname
FROM STUDENT, COURSE, ST-CRS
WHERE Cname =’Mathematics’
and
STUDENT.S_id =ST-CRS.Sno
And
COURSE.Cno =ST-CRS.Cno

7) Find names of Students who attended Course taught by Professor P10

SELECT Sname
FROM STUDENT, ST-CRS, COURSE, PROF-CRS
WHERE PROF-CRS.Pno ='P10'
And
STUDENT.S_Id =ST-CRS.Sno
And
COURSE.Cno =ST-CRS.Cno
And
COURSE.Cno =PROF-CRS.Cno

8) Find names of Students who attended a Course taught by Professor Ali

SELECT Sname
FROM STUDENT, ST-CRS, COURSE, PROF, PROF-CRS
WHERE PROF.Pname ='Ali'
And
STUDENT.S_Id =ST-CRS.Sno
And
COURSE.Cno =ST-CRS.Cno
And
COURSE.Cno =PROF-CRS.Cno
And
PROF.P_id=PROF-CRS.Pno

2
9) Find names of Students who attended a Course taught by a Professor works in
their department

SELECT Sname
FROM STUDENT, ST-CRS, COURSE, PROF, PROF-CRS
WHERE PROF.Pname ='Ali'
And
STUDENT.S_Id =ST-CRS.Sno
And
COURSE.Cno =ST-CRS.Cno
And
COURSE.Cno =PROF-CRS.Cno
And
PROF.P_id=PROF-CRS.Pno
And
STUDENT.Major=PROF.Dept

You might also like