select * from 表 a where a.级别 = (select max(b.级别) from 表 b where a.姓名 = b.姓名)
select * from 表 a where 级别=(Select max(级别) from 表 where 姓名=a.姓名)或:Select * from 表 a where 级别=(Select top 1 级别 from 表 where 姓名=a.姓名 order by 级别 desc)
Select * from 表 a where 级别 = (Select max(时间) from 表 where 姓名 = a.姓名) 或 Select * from 表 a where 级别 = (Select max(顺序) from 表 where 姓名 = a.姓名) 或 Select * from 表 a where 级别 = (Select max(级别) from 表 where 姓名 = a.姓名)
--下面的方法应该效率高一些 select a.* from 表 a join( seelct 姓名,级别=max(级别) from 表 group by 姓名 ) b on a.姓名=b.姓名 and a.级别=b.级别
Select * from 表 a where 顺序 = (Select max(顺序) from 表 where 姓名 = a.姓名)不能忽略数据类型
或
Select * from 表 a where 级别 = (Select max(顺序) from 表 where 姓名 = a.姓名)
或
Select * from 表 a where 级别 = (Select max(级别) from 表 where 姓名 = a.姓名)
select a.*
from 表 a join(
seelct 姓名,级别=max(级别) from 表 group by 姓名
) b on a.姓名=b.姓名 and a.级别=b.级别