select * from tb_login where exists(
select top 1 name,logindate from tb_login where datediff(day,logindate,getdate())=0
group by name,logindate order by logindate asc )
select name ,logindate
from(
select name,logindate,row_number()over(partition by name order by logindate)as rowid
from tb_login
where logindate= 当天
) as t
where rowid = 1