How do I remove the first character of a string and treat the remaining values as an integer in BigQuery

微笑、不失礼 提交于 2020-01-14 04:53:08

问题


I currently am working with a large data set that was pre-populated in BigQuery. I have a column of orderID's which have the following set-up: o377412876, o380940924, etc. This is stored in a string. I need to do the following and am running into problems:

1) Strip off the first character using the BigQuery query language 2) Convert the remaining (or treat the remaining values), as an integer.

I will then run a join against the values. Now, I would be abundantly happier down this operation in either Python, R, or another language. That said, the challenge I have been given based on client needs is to write all the scripts in BigQuery's querying language.


回答1:


SELECT 10 * INTEGER(REGEXP_REPLACE(x, '^.', ''))
FROM 
  (SELECT 'o1234' AS x)

12340


来源:https://stackoverflow.com/questions/20157135/how-do-i-remove-the-first-character-of-a-string-and-treat-the-remaining-values-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!