取日期最大的记录

declare @t table(date varchar(20),Number1 varchar(20),Number2 int)
insert @t select '07-07-10','abc',12
union all select '07-07-18','abc',15
union all select '07-07-18','abc',30  ---加此行
union all select '07-06-10','cdd',8
union all select '07-09-15','cdd',10
--查看测试数据
select * from @t
--查看结果
select * from @t a where not exists
       (select 1 from @t where number1=a.number1 and date>a.date)
posted on 2007-12-24 13:44  Randy0528  阅读(481)  评论(0编辑  收藏  举报