You didn't exclude "the same test number" condition. What does it mean, anyway? "same" as what? Any test number that appears under "D" name? If so, this code might solve your problem:
Code:
SELECT NAME, TEST
FROM my_table
WHERE NAME <> 'D'
AND TEST NOT IN (SELECT TEST
FROM my_table
WHERE NAME = 'D');
P.S. You didn't mention your SQL engine; I hope this Oracle SQL code will work on your system too.