遮蔽姓名列

huangapple go评论74阅读模式
英文:

Masking Name Column

问题

我需要遮蔽我的报告中的账号和姓名数据。我的表格如下:

ACC_NUM NAME
100000111 THISISMYNAME
100000522 EVAN DIMASATRIO
100000631 THIS IS MYNAME
100000851 RAUL HOLMES
100000999 RAUL HOLMES AGUSTINA

我需要在ACC_NUM列显示最后3位数字,并在NAME列的每个单词的开头显示前3位数字。我可以使用CONCAT('xxxxxxx', RIGHT(ACC_NUM, 3))来处理ACC_NUM列,但我找不到一种方法来遮蔽NAME列。

我的期望输出如下:

MASK_ACC NAME
xxxxxxx111 THIXXXXX
xxxxxxx522 EVAXXXXX DIMXXXXX
xxxxxxx631 THIXXXXX IS MYNXXXXX
xxxxxxx851 RAUXXXXX HOLXXXXX
xxxxxxx851 RAUXXXXX HOLXXXXX AGUXXXXX

这是我的dbfiddle链接:https://dbfiddle.uk/3K_MpRoE

英文:

I need to mask the account number and name data from my reports. My table looks like this

ACC_NUM NAME
100000111 THISISMYNAME
100000522 EVAN DIMASATRIO
100000631 THIS IS MYNAME
100000851 RAUL HOLMES
100000999 RAUL HOLMES AGUSTINA

I need to show the last 3 digits for the ACC_NUM column and the first 3 digits from every word for the NAME column. I can use CONCAT('xxxxxxx', RIGHT(ACC_NUM, 3)) for the ACC_NUM column, but I can't find a way to mask the NAME column.

My expected output is something like this

MASK_ACC NAME
xxxxxxx111 THIXXXXX
xxxxxxx522 EVAXXXXX DIMXXXXX
xxxxxxx631 THIXXXXX IS MYNXXXXX
xxxxxxx851 RAUXXXXX HOLXXXXX
xxxxxxx851 RAUXXXXX HOLXXXXX AGUXXXXX

This is my dbfiddle link: https://dbfiddle.uk/3K_MpRoE

答案1

得分: -1

substring(x.acc_num,1,0)+'*****'+substring(x.acc_num,len(x.acc_num)-2,len(x.acc_num)) from acc x

英文:

Select substring(x.acc_num,1,0)+'*****'+substring(x.acc_num,len(x.acc_num)-2,len(x.acc_num)) from acc x

答案2

得分: -1

我找到了,大家,我会使用这个查询:

REGEXP_REPLACE(NAME, '([A-Z]{3})([A-Z]+)', '****')

这是 dbfiddle 链接:https://dbfiddle.uk/4QGiz9RF

英文:

I found it everyone, I will use this query

REGEXP_REPLACE(NAME, '([A-Z]{3})([A-Z]+)', '****')

This is the dbfiddle: https://dbfiddle.uk/4QGiz9RF

huangapple
  • 本文由 发表于 2023年6月26日 12:28:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76553519.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定