记录如下: id xno 1 2 3 2 2 2 1 3 2 3 3 3 4 3 4 3 通过SQL语句,最后是要把 同一组xno中,id最大找出来.结果如下: id xno 3 2 4 3 4 3 语句如下:
1、select * from table1 where (id,xno) in (select max(id),xno from table1 group by xno).
2、select max(id) as maxid,xno from tablename group by xno
|