Name: Musawer Sadeq Period: 7 Date: 2/18/2025
1. Find all juniors and seniors, but only show their ID, first name, last name, and class.
sql
SELECT StudentID, FirstName, LastName, StdClass
FROM Students
WHERE StdClass IN ('JR', 'SR');
This grabs only juniors and seniors from the list of students.
2. Show students who are majoring in Computer Science.
sql
SELECT StudentID, FirstName, LastName, Major
FROM Students
WHERE Major = 'Computer Science';
This pulls only the students whose major is Computer Science.
3. List students with their advisor's name.
sql
SELECT Students.FirstName, Students.LastName, Faculty.FacFirstName,
Faculty.FacLastName
FROM Students
JOIN Faculty ON Students.AdvisorID = Faculty.FacSSN;
This links the Students table with the Faculty table, so we can see who advises who.
4. Count how many students are in each major.
sql
SELECT Major, COUNT(*) AS TotalStudents
FROM Students
GROUP BY Major;
This counts how many students are in each major.
5. Find departments where the average faculty salary is over $60,000.
sql
SELECT DeptName, AVG(FacSalary) AS AvgSalary
FROM Faculty
GROUP BY DeptName
HAVING AVG(FacSalary) > 60000;
This checks each department and only shows the ones where faculty make more than $60K on
average.