Typical database query questions

Source: Internet
Author: User


Database classic query questions student selection course Database: S (Sid, SNAME, AGE, SEX, DEPARTMENT, ADDRESS, BIRTHPLACE) SC (Sid, Cid, GRADE) C (Cid, CNAME, TEACHER) (1) course number and name taught by instructor Li; select cid, cnamefrom cwhere teacher = 'lil' (2) Student ID and name of a girl over 23 years old; select sid, snamefrom s www.2cto.com where s. age> 23 and sex = 'female '(3) names of all courses selected by "Li Xiaobo"; select c. cnamefrom cwhere c. cid in (select SC. cid from s, SC where s. sid = SC. sid and s. sname = 'Li Xiaobo '); (4) Name and Department of all students whose scores are over 80; select sname, departmentfrom swhere sid in (select sid from SC group by sid having min (grade)> = 80); (5) name of the student who does not take the "Operating System" course; select sname from s where s. sid not in (select SC. sid from SC, c where SC. cid = c. cid and c. cname = 'OS') (6) Name and Department of boys in the same township as "Li Xiaobo"; select s. sname, s. department from s www.2cto.com where s. sex = 'male' and s. birthplace = (select s. birthplace from s where s. sname = 'Li Xiaobo '); (7) students with better English scores than mathematics scores; (8) list of students with better English scores than boys who take the same course; (9) name and gender of the students who take at least two courses; (10) Number of students who have taken the courses taught by Mr. Li; (11) students who have not taken the courses taught by Mr. Li; (12) name, gender, and Department of the student with the highest score in the "Operating System" course;
Author radio123

Related Article

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.