Hi,
try this
Declare @t table (UserName varchar(10),_date date ,_time time , LoginStatus bit )
insert into @t
values
('user1 ',GETDATE()-1,'12:30',0),('user1 ',GETDATE()-1,'13:30',1),('user1 ',GETDATE()-1,'14:30',0),
('user2 ',GETDATE(),'14:30',0),('user2 ',GETDATE(),'15:30',1),('user2',GETDATE(),'16:30',0),('user2',GETDATE(),'17:30',1)
Select UserName,_date,_time,LoginStatus
from
( Select * ,ROW_NUMBER() over (partition by username order by _date,_time desc ) rk
from @t) A
where rk=1
output is
UserName _date _time LoginStatus
user1 2015-04-23 14:30:00.0000000 0
user2 2015-04-24 17:30:00.0000000 1