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