
[英]Oracle SQL Developer how to get a sum from the result of another query
[英]Replace Characters from result Oracle SQL developer
我一直在尝试解决我在获取 MOBILE NO 时遇到的问题,我搜索了每个地方以替换我的MOBILE
列中的一些字符。 我试过regexp_replace(mobile, '03', '+923') as MOBILE
和replace(mobile, '03', '+923') as MOBILE
in ORACLE SQL DEVELOPER列,但我一直面临的问题是我的一些列记录在列中间有这些字符,这些字符也被此查询替换。 我的查询是这样的:
select replace(mobile, '03', '+923') as MOBILE
from detail_accounts
我得到的结果是:
MOBILE
--------------
+9230+923182802
+9230+923159381
+9230+923135716
+9230+923120242
+9230+923113709
+9230+923113707
+9230+923112794
+9230+923082646
+9230+923061622
+9230+923+923+92357
+9230+923023594
+9230+923016147
+9230+923015115
+9230+923010297
+9230+9230+923075
--------------
没有替换 function 的原始列的结果是:
MOBILE
--------------
03003182802
03003159381
03003135716
03003120242
03003113709
03003113707
03003112794
03003082646
03003061622
03003030357
03003023594
03003016147
03003015115
03003010297
03003003075
--------------
如果有什么困惑,请问我。 我尽力在 StackOverflow 上获得相关问题,如果我问了一个已经回答的问题,请原谅我。 谢谢!
您可以使用regex_replace
select regexp_replace('03003182802','03','+923',1,1) from dual
Output
+923003182802
为您查询
select regexp_replace(mobile,'03','+923',1,1) as MOBILE
from detail_accounts
您可以尝试以下操作,模式 '^03' 将查找与字符串开头匹配的字符串,然后将其替换为 '+923'
例如:
select '03003182802' as orig_num,regexp_replace('03003182802','^03','+923') as replaced_num
from dual
https://dbfiddle.uk/?rdbms=oracle_11.2&fiddle=d81d09298cc499d5c30f200d45b20c15
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.