(sbid varchar(10), revtime datetime, interfacetype int, value numeric(12,2))
insert into t
select '08312', '2007-8-11 11:00:00', 7 , 12.90 union all
select '08312', '2007-8-11 12:00:00', 7 , 12.21 union all
select '08312', '2007-8-11 12:00:00', 10, 112.90
select * from t a
where not exists(select 1 from t where interfacetype=a.interfacetype and revtime >a.revtime)
declare @test table (sbid varchar(10), revtime datetime, interfacetype int, value money)
insert @test
select '08312', '2007-8-11 11:00:00', '7', 12.90 union all
select '08312', '2007-8-11 12:00:00', '7', 12.21 union all
select '08312', '2007-8-11 12:00:00', '10', 112.90
select * from @Test a where revtime in (select top 1 revtime from @Test where interfacetype = a.interfacetype order by revtime desc)
-- or
select * from @Test a where revtime in (select max(revtime) from @Test where interfacetype = a.interfacetype)
(sbid varchar(10), revtime datetime, interfacetype int, value numeric(12,2))
insert into t
select '08312', '2007-8-11 11:00:00', 7 , 12.90 union all
select '08312', '2007-8-11 12:00:00', 7 , 12.21 union all
select '08312', '2007-8-11 12:00:00', 10, 112.90
select * from t a
where not exists(select 1 from t where interfacetype=a.interfacetype and revtime >a.revtime)