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 names of students with more than 80 points in each course, with the following data table structure:

The table SQL is built as follows:

SETForeign_key_checks=0;-- ------------------------------Table structure for grade-- ----------------------------DROP TABLE IF EXISTS' grade ';CREATE TABLE' grade ' (' name 'varchar(255) not NULL, ' class 'varchar(255) not NULL, ' score 'tinyint(4) not NULL) ENGINE=InnoDBDEFAULTCHARSET=utf8mb4;-- ------------------------------Records of Grade-- ----------------------------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',' -');INSERT  into' Grade 'VALUES('Harry','English',' -');SETForeign_key_checks=1;

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

SELECT DISTINCT  from WHERE  not inch (SELECTDISTINCTfromWHERE<=);

The name of the student whose average score is greater than 80:

SELECT  from (SELECTCOUNT(* as T,SUMas fromGROUP  by asWHERE>*t;

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.