In Microsoft SQL Server, the IIF function is a shorthand way to perform conditional logic, similar to the CASE statement. It evaluates a condition and returns one value if the condition is TRUE, and ...
Many assume that CASE and IIF short-circuit like if-else statements in traditional programming — but in SQL, that's not guaranteed, especially when aggregates like MIN () or MAX () are involved.