如何获得雪花中包含行的数字
我尝试过REGEXP,REGEXP_LIKE和LIKE,但不起作用
从B 中select *
- regexp_like(col1,'\ d'),
- 其中regexp_like(col1,'[0-9])
- ... .etc
我们有此表
col1 |
---|
avr100000 |
adfdsgwr |
20170910020359.761 |
企业 |
adf56ds76gwr |
+093000 |
080000 |
adfdsgwr |
col1
avr100000
20170910020359.761
adf56ds76gwr
0+093000
1080000
0 谢谢
I have tried regexp, regexp_like and like but didn't work
select * from b
- where regexp_like(col1, '\d')
- where regexp_like(col1, '[0-9]')
- ....etc
we have this table
Col1 |
---|
avr100000 |
adfdsgwr |
20170910020359.761 |
Enterprise |
adf56ds76gwr |
0+093000 |
080000 |
adfdsgwr |
output should be these 5 rows
col1
avr100000
20170910020359.761
adf56ds76gwr
0+093000
1080000
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在WHERE子句中使用
REGEXP_INSTR
,以查看是否在字符串中的任何位置找到一个数字:我正在将答案更新到请注意,请注意
Regexp_instr
将执行约3.88比使用REGEXP_COUNT
的时间快。原因是
REGEXP_INSTR
将停止并报告其遇到的第一个数字的位置。相比之下,Regexp_count
将继续检查字符串,直到达到其末端为止。如果我们只想知道字符串中是否存在一个数字,我们就可以在遇到第一个数字后立即停止。如果这是一个小数据集,则无关紧要。对于大型数据集,快3.8倍的速度有很大的不同。这是一个小型测试安全带,显示了性能差异:
You can use
regexp_instr
in the where clause to see if it finds a digit anywhere in the string:I'm updating my answer to note that
regexp_instr
is going to perform about 3.8 times faster than usingregexp_count
for this requirement.The reason is that
regexp_instr
will stop and report the location of the first digit it encounters. In contrast,regexp_count
will continue examining the string until it reaches its end. If we only want to know if a digit exists in a string, we can stop as soon as we encounter the first one.If it is a small data set, this won't matter much. For large data sets, that 3.8 times faster makes a big difference. Here is a mini test harness that shows the performance difference:
一种方法是计算有多少个alpha令牌:
,从而排除那些不在的地方:
:INPUT 0:INPUT 0 :
One method is to count how many alpha tokens there are:
and thus exclude those where it is not zero:
gives:
您需要做的就是找到一个数值的1个或更多实例:
结果:
All you need to do is find 1 or more instances of a numeric value:
Results: