日期:2014-05-18 浏览次数:20489 次
select * from test a where a.Time=(select max(Time) from test b where a.Date =b.Date)
------解决方案--------------------
--#1. select A.*, B.name, B.ID from ( select Date = convert(char(10), Date, 120), Time = max(Time) from SignIn group by convert(char(10), Date, 120) ) A inner join SignIn B on A.Date = B.Date and A.Time = B.time --#2. select B.* from (select distinct [Date] from SignIn) A cross apply (select top(1) * from SignIn where [Date] = A.[Date] order by [Time] desc) B