日期:2014-05-18 浏览次数:20498 次
create table Test (ID int identity (1,1),UserName varchar(10),Times datetime) insert into Test values('张三','2012-01-02 09:21:21') insert into Test values('张三','2012-01-02 23:23:23') insert into Test values('张四','2012-01-03 09:21:21') select UserName,Min(Times) from Test group by UserName
------解决方案--------------------
select id,name,[datetime] from
(select *,row_number() over(partition by name order by [datetime]) as rownum
from tab) as tb1
where rownum<2