select t.*from (select t.*, (@rn := if(@s = subject, @rn + 1, if(@s := subject, 1, 1) ) ) as rn from t cross join(select @rn := 0, @s := '') params order by subject, marks desc ) t where rn <= 3order by t.subject, t.rn;
欢迎分享,转载请注明来源:内存溢出
select t.*from (select t.*, (@rn := if(@s = subject, @rn + 1, if(@s := subject, 1, 1) ) ) as rn from t cross join(select @rn := 0, @s := '') params order by subject, marks desc ) t where rn <= 3order by t.subject, t.rn;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)