create table temp1 ( class nvarchar(10), dt datetime)
insert into temp1
select 'A ', 42
union select 'A ', '2008-10-21 00:00:00'
union select 'B ', '2008-10-20 00:00:00'
union select 'B ', '2008-10-11 00:00:00'
union select 'B ', '2008-10-12 01:00:00'
union select 'C ', '2008-10-13 00:00:00'
union select 'C ', '2008-10-21 02:00:00'
union select 'C ', '2008-10-21 03:00:00'
insert into temp1 select 'A ', '2008-10-21 04:00:00'
insert into temp1 select 'A ', '2008-10-21 05:00:00'
insert into temp1 select 'A ', '2008-10-21 05:00:00'
insert into temp1 select 'A ', '2008-10-21 06:00:00'
insert into temp1 select 'A ', '2008-10-21 07:00:00'
insert into temp1 select 'A ', '2008-10-21 08:00:00'
select * from temp1
select class,dt from temp1 a
where (select Count(1) from temp1 b where a.class=b.class and a.dt <b.dt ) <2
order by class,dt desc
drop table temp1