You're making it too complicated. Your conditions are logically:
rows where code = E
rows where code in A ~ D and age between 0 and 120
That should give you an idea about how to formulate your where clause. That is one way, and I can think of another involving a case expression. Note that case is not a control-of-flow construct in tsql. It is an expression that returns
a scalar value. So you could try something like:
... where (case Code when E then 0 else datediff ... end) between 0 and 120
Try it both ways and review the execution plan to see which one is more efficient.
Microsoft is conducting an online survey to understand your opinion of the Technet Web site. If you choose to participate, the online survey will be presented to you when you leave the Technet Web site.