I have a table:
Account_Code | Desc
503100 | account xxx
503103 | account xxx
503104 | account xxx
503102A | account xxx
503110B
I think the problem is not in sub-query but in WHERE clause of outer query. When you use
WHERE account_code between 503100 and 503105
SQL server will try to convert every value in your Account_code field to integer to test it in provided condition. Obviously it will fail to do so if there will be non-integer characters in some rows.