Это довольно простой вариант использования оконной функции, на которую ссылается Common Table Expression (CTE):
Query
declare @t table(Student varchar(10),Task int,Result varchar(10),Reason varchar(50));
insert into @t values('Jim' ,3,'Success',NULL),('Jim' ,4,'Success',NULL),('John',3,'Success',NULL),('John',2,'Failed ','Task finished too late'),('Bill',5,'Success',NULL),('Bill',7,'Failed ','Not enough knowledge'),('Bill',6,'Unknown','Asked StackOverflow to do his homework');
with s as
(
select *
,sum(case when Result <> 'Success' then 1 else 0 end) over (partition by Student) as NonSuccesses
from @t
)
select Student
,Task
,Result
,Reason
from s
where Result <> 'Success'
or NonSuccesses = 0;
Output
+---------+------+---------+----------------------------------------+
| Student | Task | Result | Reason |
+---------+------+---------+----------------------------------------+
| Bill | 7 | Failed | Not enough knowledge |
| Bill | 6 | Unknown | Asked StackOverflow to do his homework |
| Jim | 3 | Success | NULL |
| Jim | 4 | Success | NULL |
| John | 2 | Failed | Task finished too late |
+---------+------+---------+----------------------------------------+