SQL_Practical_Solutions
SQL_Practical_Solutions
Insert a new teacher named 'Mr. Kofi Ansah' in the Mathematics department
INSERT INTO Teachers (teacher_id, full_name, department)
VALUES (1, 'Mr. Kofi Ansah', 'Mathematics');
List all departments and the total number of teachers in each department
SELECT department, COUNT(*) AS total_teachers FROM Teachers GROUP BY department;
Retrieve the names of students and their respective grades in all courses, sorted by grade in
descending order
SELECT Students.first_name, Students.last_name, Enrollments.grade
FROM Students
JOIN Enrollments ON Students.student_id = Enrollments.student_id
ORDER BY Enrollments.grade DESC;
Retrieve the list of students who are enrolled in more than one course
SELECT Students.first_name, Students.last_name
FROM Students
JOIN Enrollments ON Students.student_id = Enrollments.student_id
GROUP BY Students.student_id
HAVING COUNT(Enrollments.course_id) > 1;