skip to Main Content

table

ACC_NO      pre_val    New_val
123489432   123489432  123489435
123489532   123489532  123489435

I asked some of my friends but not getting how to write the sql query.

2

Answers


  1. Your question is a bit unclear but, I guess you want something like that(?)

     SELECT LPAD(RIGHT(ACC_NO, 4),9, "*");
    
    Login or Signup to reply.
  2. Extract the last 4 digits with RIGHT() and concatenate them with the asterisks that replace the first 5 digits.

    SELECT ACC_NO, CONCAT('*****', RIGHT(pre_val, 4)) AS pre_val, CONCAT('*****', RIGHT(new_val, 4)) AS new_val
    FROM yourTable
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search