日期:2014-05-18  浏览次数:20600 次

SQL按某一字段分别取多行记录 每行记录的数据需取该行某字段最大值
表如下
1 2
1 3
1 4
2 5
2 6
2 7
9 4
9 5
9 6
得到结果
1 4
2 7
9 6

------解决方案--------------------
SQL code

select a,max(b) b
from tb
group by a

------解决方案--------------------
SQL code
select col1,max(col2) as col2 from tb group by col1