现在的位置: 首页 > 综合 > 正文

取日期最大的记录

2011年07月07日 ⁄ 综合 ⁄ 共 344字 ⁄ 字号 评论关闭
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)

抱歉!评论已关闭.