The RIGHT function returns a specified number of characters from the end, or right side, of a string.
Business identifiers often contain meaningful suffixes. RIGHT can extract those values for classification and analysis.
Extract the last four characters of an account number.
SELECT
AccountNumber,
RIGHT(AccountNumber, 4) AS LastFourDigits
FROM Accounts;
RIGHT is useful for account masking, extracting suffixes, product codes, branch identifiers, and validation.
- RIGHT extracts characters from the end.
- The number of characters can be specified.
- It is useful for identifiers.
- It can support masking and validation.
- Syntax may vary between databases.
What does RIGHT do?
RIGHT returns a specified number of characters from the end of a string.
Why is RIGHT useful with account numbers?
It can extract the final digits needed for identification or masked reporting without displaying the full account number.