I'm maintaining someone else's SQL at the moment, and I came across this in a Stored Procedure:
SELECT
Location.ID,
Location.Location,
COUNT(Person.ID) As CountAdultMales
FROM
Transactions INNER JOIN
Location ON Transactions.FKLocationID = Location.ID INNER JOIN
Person ON Transactions.FKPersonID = Person.ID
AND DATEDIFF(YEAR, Person.DateOfBirth, GETDATE()) >= 18 AND Person.Gender = 1
WHERE
((Transactions.Deleted = 0) AND
(Person.Deleted = 0) AND
(Location.Deleted = 0))
Is there any difference between the above and this (which is how I would write it)
SELECT
Location.ID,
Location.Location,
COUNT(Person.ID) As CountAdultMales
FROM
Transactions INNER JOIN
Location ON Transactions.FKLocationID = Location.ID INNER JOIN
Person ON Transactions.FKPersonID = Person.ID
WHERE
((Transactions.Deleted = 0) AND
(Person.Deleted = 0) AND
(Location.Deleted = 0) AND
(DATEDIFF(YEAR, Person.DateOfBirth, GETDATE()) >= 18) AND
(Person.Gender = 1))
Personally, I find putting the conditions in the WHERE clause most readable, but I wondered if there were performance or other reasons to "conditionalise" (if there is such a word) the JOIN
Thanks