Search code examples
sqlnetezza

How to Masking account number in sql (NETEZZA)


I have an 8 digit account number I want to mask last three to XXX I am working with IBM Netezza database.

for eg: 34567890 output: 34567XXX

Could someone please tell me the syntax for the same.


Solution

  • You can use:

    select strleft(account, length(account) - 3) || 'XXX'
    

    Or if all accounts are exactly 8 characters:

    select strleft(account, 5) || 'XXX'