In a SQL query, I have an "If, Then" statement (i.e. a "Select Case When" statement). That part of the query represents a field (column) named "[CurrentTrxAmt]". That field's name, as you can tell, is in brackets.
Later in the query, I need to use that particular "If, Then" statement within another "If, Then" statement. That second "If, Then" statement is to say "If this happens, then use the results of that first 'If, Then' statement".
Truthfully, what I would like to do is to take that bracketed "[CurrentTrxAmt]" field and nest it within that second "If, Then" statement rather than re-typing that entire first "If, Then" statement. But, when I try that, SQL gives me an error message basically saying that there is no such thing as that bracketed field. It's one of those situations where, when you have a bracketed field name, SQL will not let you use that bracketed name again later in that same query.
Nevertheless, how do I nest that very complex first "If, Then" statement within the second?
Attached is the code. I want to use [CurrentTrxAmt] within [NotDue]. The [NotDue] field is the seconfd "If, Then" statement that I referred to earlier.