Please use SQL to find out the top three in each class

There is a table of student grades in the MYSQL database

table name: table

Fields: student (student), class (class), total (total score)

Field description: Class ranges from 1 to 10, a total of 10 classes.

Please use SQL to find out the top three in each class

 

 

select *
from tb t
where (select count(1)+1 from tb where class=t.class and marks>t.marks)<=3;

select *
from tb t;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324897074&siteId=291194637