Question stem:
Query the student numbers and average grades of students who have taken more than 2 courses.
Tips: Please use the SELECT statement to answer, and the average score is rounded up to keep 1 valid figure.
Table Structure:
The SQL statement defining the table structure is as follows:
CREATE TABLE score (
sno varchar(6) NOT NULL,
cno varchar(6) NOT NULL,
term varchar(15),
grade int(11),
PRIMARY KEY (sno,cno)
) ;
table sample
The table sample corresponding to the above table structure, some data are as follows:
score table:
Sample output:
Sample output:
Code length limit 16 KB
Time limit 400 ms
DatabaseMySQL
The result output requires a strict comparison of the order and data
select sno 学号, round(avg(grade),1) 平均成绩
from score
group by sno
having count(sno) >= 2