see the below query,
might it helps...
select a.StaffNo,a.Date, SUBSTRING(b.alltime ,1, LEN(b.alltime ) - 1) from
(select distinct StaffNo, Date from tablename) A cross apply
(select time +',' from tablename where id=a.StaffNo and name=a.Date for xml path('')) B (alltime)