posted 11 years ago
Interesting. I'd say that this is because the EXIST condition just looks whether the subquery returns any row, but doesn't evaluate any expressions in the SELECT clause. It doesn't have to - the existence of rows depends only on the WHERE clause, not on the expressions in the SELECT clause.
This particular case illustrates a general aspect of SQL, which is that you don't have any control over how many times and in which order individual expressions in your SQL statements will be evaluated. This has consequences especially when calling stored procedures from SQL statements, where the number of times they get called may be significant (unlike in pure SQL, where it doesn't matter).