There are three basic tables in the teaching database:
Student Table S (s#,sname,age,sex), whose attributes indicate student's number, name, age and gender; elective courses table SC (S#,c#,grade), whose attributes represent the student's number, course number and grade of the course, curriculum C (C#,cname,teacher), whose properties represent the course number, course name and the name of the instructor. The following topics are for the above three basic table operations.
(1) Write the SQL statement that retrieves the course number of the course that is the subject of the female classmate.
Select C #
From S,SC
where S.S#=SC. s# and s.sex= ' women '
(2) write the SQL statement for the following insert operation: Insert the average score for each course in the SC table into another existing table Sc_c (C#,cname, Avg_grade), where Avg_grade is the average score for each course.
INSERT INTO Sc_c
Select SC. C#,c.cname,avg (SC. GRADE)
From Sc,c
GROUP BY C #
(3) Try out the SQL statement of the following delete operation: from the SC table, the female students in Wu's class were deleted.
Delete from SC
where s# in
(select s# from S where sex= ' female ')
and C # in
(select C # from C where teacher= ' WU ')
Database questions: Student table, schedule, timetable