27,579
社区成员
发帖
与我相关
我的任务
分享
declare @A table
(movid int,movname varchar(6),movno int,movtype int,movjpg varchar(6),updatetime datetime)
insert into @A
select 1,'好朋友',2,5,'1.jpg','2012-10-15' union all
select 3,'好朋友',3,5,'1.jpg','2012-10-15' union all
select 4,'三国',1,2,'4.jpg','2012-3-10' union all
select 5,'老友记',6,10,'6.jpg','2011-6-9' union all
select 12,'三国',7,2,'4.jpg','2012-3-10' union all
select 16,'老朋友',6,4,'12.jpg','2010-3-5' union all
select 17,'老朋友',8,4,'12.jpg','2010-3-5' union all
select 19,'老朋友',11,4,'12.jpg','2010-3-5'
select * from @A t
where movno=(select min(movno) from @A where movname=t.movname)
order by updatetime DESC
/*
movid movname movno movtype movjpg updatetime
----------- ------- ----------- ----------- ------ -----------------------
1 好朋友 2 5 1.jpg 2012-10-15 00:00:00.000
4 三国 1 2 4.jpg 2012-03-10 00:00:00.000
5 老友记 6 10 6.jpg 2011-06-09 00:00:00.000
16 老朋友 6 4 12.jpg 2010-03-05 00:00:00.000
*/
select aa.* from aa,(select MIN(movno)as movno from aa)as b where aa.movno=b.movno
order by updatetime desc