EX06 SQL Query
EX06 SQL Query
STUDENT
SUBJECT:
SubjectID SubjectName
101 Toán
102 Lý
103 Hóa
104 Văn
COURSE
SUBJECT_ENROLMENT
StudentID SubjectID FeesPaidDate
1 101 2023-01-15
1 102 2023-02-20
1 105 2023-03-10
2 101 2023-04-05
2 103
3 102 2023-01-10
3 104 2023-05-18
4 105 2023-06-01
5 103
6 101 2023-02-28
7 102 2023-03-15
8 104 2023-01-01
9 105
10 101 2023-04-12
1. Retrieve all students from the STUDENT table.
2. Find the name and address of the student with StudentID = 1.
3. List all subjects in the SUBJECT table.
4. Find the name of the teacher with TeacherID = 202.
5. Retrieve the course name for the course with CourseID = 301.
6. Find all students who were born after '2000-01-01'.
7. Retrieve all students who live in 'Hà Nội'.
8. List all teachers who live in 'Đà Nẵng'.
9. Find all subjects where the fees paid is greater than 400000.
10. List all students who have paid fees after '2023-01-01'.
11. Find the names of students who are enrolled in at least 2 different subjects.
12. Retrieve the details of students who have not yet paid their fees for any subject.
13. Find the total fees paid by the student with StudentID = 1.
14. List all courses taught by the teacher with TeacherID = 201.
15. Find all subjects that have at least one student enrolled.
16. Retrieve the names of students enrolled in the subject with SubjectID = 101.
17. Find the teachers who teach the course with CourseID = 303.
18. List all students who share the same date of birth as Lê Văn K.
19. Retrieve the list of subjects along with the number of students enrolled in each.
20. Find the total number of courses each teacher teaches.
21. Find the names of students who have paid their fees but have not yet enrolled in any courses.
22. List the subjects that have more than 5 students enrolled but less than 3 have paid their fees.
23. Find the names of teachers who teach courses that do not have any students enrolled.
24. Retrieve the students who have paid the highest fees for any subject.
25. List all courses where every student enrolled has already paid their fees.
26. Find the teachers who live in the same city as more than 3 students.
27. Retrieve the students who are enrolled in more than one subject.
28. List all students along with the total fees they have paid, sorted by the total fees.
29. Find the courses that are taught by at least 2 different teachers.
30. Retrieve the details of all students who have enrolled in a subject but haven't paid their fees
yet.