1. translate把要改的挑出
2.replace掉
You want convert a full name into initials. Consider the following name:
Stewie Griffin
You would like to return:
S.G.
select replace ( translate (ename, 'abcdefghijklmnopqrstuvwxyz',rpad('a',26,'a.')),'a','' )
from emp_1
where esal = '2000'
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23895263/viewspace-681368/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23895263/viewspace-681368/
本文介绍了一种使用SQL语句将全名转换为姓名首字母缩写的技巧。通过translate和replace函数组合实现,例如将StewieGriffin转换为S.G.。此方法适用于数据库操作中对员工姓名进行标准化处理。

被折叠的 条评论
为什么被折叠?



