Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a column that has data like this:
TEXT000612
TEXT721
TEXT8
Expected output:
000612
721
8
The column only has a 4 letter text text and its only at the beginning at the cell. But the numbers can vary in length. Also, I want to make sure the numbers are string.
There is no mid function in BQ.
Also, if you dont like my question or think it needs to be improve please give me a chance to improve it before flagging it.
Few options for BigQuery Standard SQL
#standardSQL
SELECT col,
SUBSTR(col, 5),
REGEXP_REPLACE(col, r'^TEXT', '')
FROM `project.dataset.table`
If you just want the numbers, use substr():
substr(col, 5)
You can cast() this to a number if you want.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 months ago.
Improve this question
How can I find data that dont end with letter 'g' without using NOT LIKE function, please help
select * from table where right(column, 1) != 'g'
Since you asked how to do it using "not like," I'll answer that. The function version provided by #Zoories would be more efficient.
This works at w3schools.com
SELECT * FROM Customers where CustomerName not like '%g';
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to find if the difference between 2 columns. How do I achieve that?
For example,
select(col1-col2) output is 1
select(col2-col1) output is -1
Is there a way to get just the difference as 1 without the negative (-) sign?
use abs() function
select abs(col2-col1) as diff
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have string like below
ThisSentence.should.split.beforeFirstPeriod.ofTheSentence
I want to select ThisSentence.
How can I do it with regexp_substr()?
Simple SUBSTR() and INSTR() can do the same job:
SUBSTR(YourString, 0, INSTR(YourString, '.')-1)
Sagi's answer is correct. However, Oracle also offers regexp_substr() which provides more general functionality:
select regexp_substr(str, '[^.]+', 1, 1)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
You can I display special Unicode characters in my result set on my SQL Server?
e.g. How can i display those characters ☺♦♦?
Well due to the fact that your question is very unspecific here are some solutions.
You need to specify a string as unicode string. This can be achieved by adding an N in front of the string. See example:
SELECT N'☺♦♦' as a, '☺♦♦' as b
Result:
a b
---- ----
☺♦♦ ???
If you want to store those symbols, you need a type as nvarchar or nchar.
Hopefully this helps you.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am using Oracle SQL developer 2012. My data looks like 'valueA-valueB'. I want to strip the content after - and populate with rest.
You can use a combination of substr and instr:
SELECT SUBSTR(my_column, 1, INSTR(my_column, '-') - 1)
FROM my_table