Use an SQL statement to find out the names of students who have more than 80 points per course

Source: Internet
Author: User

Use an SQL statement to find out the list of students with all courses that are greater than 80 points:

Name Cource Score
Tom Chinese 81
Tom Mathematical 75
John doe Chinese 76
John doe Mathematical 90
Harry Chinese 81
Harry Mathematical 100
Harry English 90

1 SETForeign_key_checks=0;2 3 -- ----------------------------4 --Table structure for grade5 -- ----------------------------6 DROP TABLE IF EXISTS' grade ';7 CREATE TABLE' Grade ' (8' Name 'varchar(255) not NULL,9' Class 'varchar(255) not NULL,Ten' Score 'tinyint(4) not NULL One) ENGINE=InnoDBDEFAULTCHARSET=utf8mb4; A  - -- ---------------------------- - --Records of Grade the -- ---------------------------- - INSERT  into' Grade 'VALUES('Zhang San','language','Bayi'); - INSERT  into' Grade 'VALUES('Zhang San','Mathematics',' the'); - INSERT  into' Grade 'VALUES('John Doe','language',' the'); + INSERT  into' Grade 'VALUES('John Doe','Mathematics',' -'); - INSERT  into' Grade 'VALUES('Harry','language','Bayi'); + INSERT  into' Grade 'VALUES('Harry','Mathematics',' -'); A INSERT  into' Grade 'VALUES('Harry','English',' -'); at SETForeign_key_checks=1;
View Code

Check the names of students who have more than 80 points for each course:

1 Select distinct  from where  not inch (Selectdistinctfromwhere score<=);
View Code

There is also a simple notation:

1 Select  from Group  by  having min (score) > ;
View Code

A list of students with an average score greater than 80:

1 Select  from (2    Select Count (*sumfrom thegroup  by       name3as  where a.num>t;
View Code

There is also a simple notation:

1 Select avg  as  from Group  by  having avg (score) > ;
View Code

Use an SQL statement to find out the names of students who have more than 80 points per course

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.