Sortid (Type) Name CreateTime1 20071 English 20042 20062 3 20043 A 20053 20043 I 2003 Query each type of CreateTime second and third largest record Sortid (Type) Name CreateTime
1 English 2004
2 three 2004
3 20043 I 2003
SQL statement Select * from FROM table awhere (select count (*) from table where sortid = a.sortid and createtime> = a.createtime) in (2, 3)
Statement Analysis CreateTime> = a.createtime) In (2, 3) Only two or three greater than or equal to the current record of course is the second and third maximum record