提取数据如果
我是SQL的新手,并接受了培训,使我能够在3月使用SSR,但我们也有Oracle DB。
我需要提取可以在称为家庭电话,工作电话或手机的列中保存的电话号码,但我只想在数字启动07但也限制为11位时提取。这里的问题是数字可以在所有或任何3列中。
如果数字以07以外的其他内容开头,或者数据具有文本,我想用空白替换。
我已经考虑使用
“”选择家庭电话, 工作电话, 移动号
DB的 在哪里家庭手机,例如“ 07”% 和像'07'%的手机一样 移动不像“ 07'%”''
,但这大大减少了预期的数据集。
我已经看了替换和regexp-replact,但在一分钟内不能完全抓住我的头。任何帮助都非常感谢,我认为如果不是11位手机号码,则要导出所有数据,只有空白。
I am new to SQL and had training to enable me to use SSRS in March but we also have an oracle DB.
I need to extract phone numbers which can be held in columns called home phone, work phone or mobile phone but I want to only extract if the number starts 07 but also limit to 11 digits. The issue here is the number could be in all or any 3 of the columns.
If the number starts with anything other than 07 or if the data has text, I want to replace this with a blank.
I have looked at using
'''Select home phone,
Work phone,
Mobile no
From DB
Where home phone like '07'%
And work phone like '07'%
And mobile no like '07'%'''
But this massively reduces the data set as expected.
I have looked at replace and regexp-replace but can't quite get my head around this bit at the minute. Any help much appreciated, I think want to export all of the data just have a blank if it's not an 11 digit mobile number.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该放置或放在查询中。由于您提到您只想导出数据,因此我认为查询是将电话号码格式化如下:
您可以将其应用于SELECT work_phone和Mobile_phone。
如果这不是您想要的,请提供示例数据和所需的输出,以便我更容易复制。
You should put OR instead of AND in your query. Since you mentioned you want to export data only so I think the query is to format the phone number as below:
You can apply the same to select WORK_PHONE and MOBILE_PHONE.
If this is not what you are looking for, please give sample data and desired output so it would be easier for me to replicate.