SELECT *
FROM D
LEFT OUTER JOIN a
ON A.a = D.a
WHERE
A.b = 1 -- << this turns the LEFT OUTER JOIN into an INNER JOIN
AND D.a IN (1,2,3,4)
-- use this instead:
SELECT *
FROM D
LEFT OUTER JOIN a
ON A.a = D.a AND A.b = 1
WHERE D.a IN (1,2,3,4)
Ah, Laurie beat me to it.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden