34,837
社区成员




declare @t table(bid int,bname varchar(10),aid int,bset int,btime datetime)
insert into @t select 1,'rtrtr',1,0,null
insert into @t select 2,'trtt',1,1,'2008-03-04'
insert into @t select 3,'tret',1,1,'2008-04-01'
insert into @t select 4,'tretrt',1,1,'2008-04-20'
insert into @t select 5,'jjhj',2,0,null
insert into @t select 6,'kkjj',4,0,null
insert into @t select 7,'spdfff',2,1,'2008-04-01'
select top 3 * from @t a where bid in
(select top 1 bid from @t where aid=a.aid
and isnull(btime,getdate())>=getdate()
order by bset desc,bid )
order by bid
declare @t table(bid int,bname varchar(10),aid int,bset int,btime datetime)
insert into @t select 1,'rtrtr',1,0,null
insert into @t select 2,'trtt',1,1,'2008-03-04'
insert into @t select 3,'tret',1,1,'2008-04-01'
insert into @t select 4,'tretrt',1,1,'2008-04-20'
insert into @t select 5,'jjhj',2,0,null
insert into @t select 6,'kkjj',4,0,null
insert into @t select 7,'spdfff',2,1,'2008-04-01'
select top 3 * from @t a where bid in
(select top 1 bid from @t where aid=a.aid
and isnull(btime,getdate())>=getdate()
order by bset desc,bid )
order by bid
declare @t table(bid int,bname varchar(10),aid int,bset int,btime datetime)
insert into @t select 1,'rtrtr',1,0,null
insert into @t select 2,'trtt',1,1,'2008-03-04'
insert into @t select 3,'tret',1,1,'2008-04-01'
insert into @t select 4,'tretrt',1,1,'2008-04-20'
insert into @t select 5,'jjhj',2,0,null
insert into @t select 6,'kkjj',4,0,null
insert into @t select 7,'spdfff',2,1,'2008-04-01'
insert into @t select 8,'spdfff',5,1,'2008-04-01'
select top 3 * from @t a where bid in
(select top 1 bid from @t where aid=a.aid
and isnull(btime,getdate())>=getdate()
order by bset desc,bid )
order by bid
declare @t table(bid int,bname varchar(10),aid int,bset int,btime datetime)
insert into @t select 1,'rtrtr',1,0,null
insert into @t select 2,'trtt',1,1,'2008-03-04'
insert into @t select 3,'tret',1,1,'2008-04-01'
insert into @t select 4,'tretrt',1,1,'2008-04-20'
insert into @t select 5,'jjhj',2,0,null
insert into @t select 6,'kkjj',4,0,null
insert into @t select 7,'spdfff',2,1,'2008-04-01'
insert into @t select 8,'spdfff',5,1,'2008-04-01'
select top 3 * from @t a where bid in
(select top 1 bid from @t where aid=a.aid
and isnull(btime,getdate())>=getdate()
order by bset desc,bid )
order by bid
declare @t table(bid int,bname varchar(10),aid int,bset int,btime datetime)
insert into @t select 1,'rtrtr',1,0,null
insert into @t select 2,'trtt',1,1,'2008-03-04'
insert into @t select 3,'tret',1,1,'2008-04-01'
insert into @t select 4,'tretrt',1,1,'2008-04-20'
insert into @t select 5,'jjhj',2,0,null
insert into @t select 6,'kkjj',4,0,null
insert into @t select 7,'spdfff',2,1,'2008-04-01'
insert into @t select 8,'spdfff',5,1,'2008-04-01'
select top 3 * from @t a where bid in
(select top 1 bid from @t where aid=a.aid
and isnull(btime,getdate())>=getdate()
order by bset desc,bid )
order by bid
declare @t table(bid int,bname varchar(10),aid int,bset int,btime datetime)
insert into @t select 1,'rtrtr',1,0,null
insert into @t select 2,'trtt',1,1,'2008-03-04'
insert into @t select 3,'tret',1,1,'2008-04-01'
insert into @t select 4,'tretrt',1,1,'2008-04-20'
insert into @t select 5,'jjhj',2,0,null
insert into @t select 6,'kkjj',4,0,null
insert into @t select 7,'spdfff',2,1,'2008-04-01'
insert into @t select 8,'spdfff',5,1,'2008-04-01'
select top 3 * from @t a where bid in
(select top 1 bid from @t where aid=a.aid
and isnull(btime,getdate())>=getdate()
order by bset desc,bid )
order by bid