"It Depends". If this is being used in the SELECT list of a query, you can do pretty much as you please and you'll have no problems. If it's a part of the criteria expressed in a WHERE or ON clause, you have to be REALLY care to not make the query Non_SARGable.
From your original post, I'd guess you code snippet is from an item in the SELECT list but we can't know for sure from what you posted. It would be a whole lot more helpful if you'd post the rest of the query.
Yep... I know that you can't normally include a MAX() aggregation in the WHERE or ON clauses but it's amazing what people have done to do just that.
is pronounced "ree-bar
" and is a "Modenism
" for R
First step towards the paradigm shift of writing Set Based code:
________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
"Change is inevitable... change for the better is not".
"Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"
How to post code problems
How to Post Performance Problems
Create a Tally Function (fnTally)