http://blog.csdn.net/acmain_chm/article/details/4126306
http://bbs.csdn.net/topics/390958705
我只用到了其中的特殊形式,就是 分组取最新的一条记录:
select * from (select * from Table1 order by Score desc) t group by ClsNo
利用的是 group by 只取第一条记录,所以需要先把需要的记录排序到第一位
select * from Table1 a where not exists (select 1 from Table1 where ClsNo=a.ClsNo and Score>a.Score);
这个是利用子查询先查出小于最高值的记录,再排除出最高记录(感觉绕了一圈)
原文:http://www.cnblogs.com/mitang/p/6864343.html