Database questions: Student table, Course Selection table, course schedule, course schedule

Source: Internet
Author: User

Database questions: Student table, Course Selection table, course schedule, course schedule

There are three basic tables in the teaching database:

Student table S (S #, SNAME, AGE, SEX). Its Attributes indicate the student's student ID, name, AGE, and gender. The course selection table SC (S #, C #, GRADE ), the attributes indicate the student's student ID, course number, and score. The curriculum C (C #, CNAME, TEACHER) indicates the course number, course name, and instructor name. The following questions are all about the above three basic tables.

(1) write an SQL statement to retrieve the course number of all courses selected by female students.

 

Select C #

 

From S, SC

 

Where S.S # = SC. S # and S. SEX = 'femal'

 

(2) write the following SQL statement for the insert operation: insert the average score of each course in the SC table into another existing table SC _C (C #, CNAME, AVG_GRADE, AVG_GRADE indicates the average score of each course.

 

Insert into SC _C

 

Select SC. C #, C. CNAME, AVG (SC. GRADE)

 

From SC, C

 

Group by C #

 

(3) try to write the following SQL statement for deletion: Delete the tuples of WU's female course selection from the SC table.

 

Delete from SC

 

Where S # in

 

(Select S # from S where SEX = 'female ')

 

And C # in

 

(Select C # from C where TEACHER = 'wu ')

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.