一个 分组求最大值的问题 哪位哥哥姐姐帮忙看下 谢谢了
number cxtime //字段名
6901235897453 2007-02-03 13:34:51.000
6901235897453 2007-02-03 13:42:39.000
6904589754215 2007-02-03 13:43:02.000
6901028300056 2007-02-03 13:43:20.000
6902265051015 2007-02-03 13:46:21.000
6901235894454 2007-02-03 13:48:37.000
6904586785412 2007-02-03 13:49:41.000
6925874512567 2007-02-03 13:50:01.000
6902589647123 2007-02-03 13:51:38.000
6914587562145 2007-02-03 13:51:54.000
6901235897456 2007-02-05 10:47:36.000
6901235897455 2007-02-05 10:51:15.000
6920761200232 2007-02-05 10:52:51.000
6921555581681 2007-02-05 10:53:12.000
6921568974123 2007-02-05 10:53:31.000
6921168555581 2007-02-05 10:53:52.000
6904442000113 2007-02-05 11:05:56.000
6905689456123 2007-02-05 11:06:17.000
6905847568123 2007-02-05 11:06:34.000
6902402030392 2007-02-05 11:06:54.000
6917878000459 2007-02-05 11:07:11.000
6914587562145 2007-02-05 11:07:27.000
6904586785412 2007-02-08 18:34:00.000
6904586785412 2007-02-08 19:27:00.000
6904586785412 2007-02-09 10:05:00.000 //工 25条记录
郁闷还是这个问题 上次哪位大哥给的答案 我怎么弄不出来 只好 重发一次
我现在想要 number 字段不重复 而且 只取重复记录中的最新时间的那一条 得出结果应该是 :(备注:顺序不论)
number cxtime //字段名
6901235897453 2007-02-03 13:42:39.000
6901028300056 2007-02-03 13:43:20.000
6902265051015 2007-02-03 13:46:21.000
6901235894454 2007-02-03 13:48:37.000
6904586785412 2007-02-03 13:49:41.000
6925874512567 2007-02-03 13:50:01.000
6902589647123 2007-02-03 13:51:38.000
6901235897456 2007-02-05 10:47:36.000
6901235897455 2007-02-05 10:51:15.000
6920761200232 2007-02-05 10:52:51.000
6921555581681 2007-02-05 10:53:12.000
6921568974123 2007-02-05 10:53:31.000
6921168555581 2007-02-05 10:53:52.000
6904442000113 2007-02-05 11:05:56.000
6905689456123 2007-02-05 11:06:17.000
6905847568123 2007-02-05 11:06:34.000
6902402030392 2007-02-05 11:06:54.000
6917878000459 2007-02-05 11:07:11.000
6914587562145 2007-02-05 11:07:27.000
6904586785412 2007-02-09 10:05:00.000 //共 20条记录
怎么用SQL语句实现啊 不行的话 存储过程 也行 谢谢各位 哥哥姐姐了
------解决方案--------------------if object_id( 't ') is not null
drop table t
go
create table t(number varchar(50),cxtime datetime)
insert t select '6901235897453 ', '2007-02-03 13:34:51.000 '
union all select '6901235897453 ', '2007-02-03 13:42:39.000 '
union all select '6904589754215 ', '2007-02-03 13:43:02.000 '
union all select '6901028300056 ', '2007-02-03 13:43:20.000 '
union all select '6902265051015 ', '2007-02-03 13:46:21.000 '
union all select '6901235894454 ', '2007-02-