In a recent SQL Server 2008 R2 Project, I encountered many queries in which, there was an outer Select with Field names that exactly matched the field names from the Select Statement within it. Then - after the last parenthesis around the inner query - there was a where clause.
E.g. [pseudocode]
Select Field1, Field2, Field3
From
(
Select Field1, Field2, Field3
From Table1
Inner Join Table2 ON . . . multiple joins . . .
) As A
Where Field 1 = SomeValue AND Field 2 <> SomeOtherValue
Is there a benefit to wrapping the inner Select statement in the outer Select statement rather than just adding the Where clauses to the end of the inner Select Statement?
I should add that some of the fields in the inner Select consist of Case Statements. E.g.
CASE
WHEN Year(tbl.[somedate]) = #### THEN NULL
ELSE tbl.[someotherdate]
END AS Field2
Thanks!