日期:2014-05-18 浏览次数:20669 次
--> 测试数据:[test]
if object_id('[test]') is not null
drop table [test]
create table [test](
[count_num] int,
[end_time] datetime
)
insert [test]
select 1,'2005-08-06 00:00:00.000' union all
select 2,'2005-08-07 00:00:00.000' union all
select 2,'2005-09-12 00:00:00.000' union all
select 1,'2005-12-21 00:00:00.000'
select * from test a
where a.count_num=(select MAX(b.count_num) from test b)
/*
count_num end_time
2 2005-08-07 00:00:00.000
2 2005-09-12 00:00:00.000
*/
------解决方案--------------------
select count_num ,end_time from 表 having count_num =max(count_num) group by count_num