Current location - Education and Training Encyclopedia - Resume - Sql language, there is a report form, students' names are known, how to query the ranking?
Sql language, there is a report form, students' names are known, how to query the ranking?
1, create a test table,

Create table test_score (name varchar2(20), score number);

2. Insert test data

Insert into the test_score value ('Zhang San', 85);

Insert into the test_score value ('Li Si', 90);

Insert into the test_score value ('Wang Er', 95);

Insert into the test_score value ('Wuqi', 83);

Insert into the test_score value ("Li Liu", 66);

Submit;

3. Query the total data in the table, select t.*, rowid from test _ score t;;

4. Write sql and query students' nouns according to their names. Take the student' Li Si' as an example and get the second grade. ? Select T. * from (select T. *, rank () over (order by scoredesc) rk from test _ score) where T. name =' Li Si.