打印本文 打印本文 关闭窗口 关闭窗口
sql 取各组中的最大值
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1181  更新时间:2007/11/14 12:57:37  文章录入:mintao  责任编辑:mintao

表test

id               name      record
1                 a         88
2                 b         76
3                 c         66

4                 c         90
5                 b         77
6                 a         56

7                 b         77
8                 c         67
9                 a         44
获取a b c...的最大记录数的id号
select hh.id,hh.name,hh.record from test as hh where
hh.record = (select max(record) from test  where name=hh.name)

打印本文 打印本文 关闭窗口 关闭窗口