日期:2014-05-17  浏览次数:20372 次

问个SQL的问题
各位大神,问个弱弱的问题:
有如下表 table
a b c
1 1 1
2 2 1
3 3 2
4 4 2
5 5 3
其中C列有重复的,对于有重复值的,我只取一条,这一条且是 b列最大的。。。sql咋写?

------解决方案--------------------

select a,b,c
 from
 (select a,b,c, 
             row_number() over(partition by  c order by b desc) 'rn'
   from [表名]) t
where rn=1

------解决方案--------------------
http://www.cnblogs.com/xiaofengfeng/archive/2012/11/08/2761645.html 都在里面