select tb2.name,tb2.math,max(tb2.score) from
(select a.name,a.math,a.score from tablename a,
(select name ,math,max(score) as score from tablename group by math,name) as tb1
where a.name <> = tb1.name and a.math = tb1.math and a.score < tb1.score) as tb2
group by tb2.math,tb2.name
select * from table1 A
where score = (select max(score) from table1
where math = A.math and score < (select max(score) from table1
where math = A.math)
select name from table aa
where not exists
(
select 1 from table bb where aa.math=bb.math
and bb.score<
(select max(score) from table cc where bb.math=cc.math)
and bb.score>aa.score
)
select * from table aa where not exists(select 1 from table bb where aa.math=bb.math and bb.score<(select max(score) from table cc where bb.math=cc.math) and bb.score>aa.score)