Need help targeting specific characters in a column in SQL [duplicate] - sql

This question already has answers here:
How to extract Certain nth character from a string in SQL
(4 answers)
Closed 4 years ago.
I am trying to select a column using SQL but with a condition that would ignore all values in the column that have the 4th character of the value as 0.
For example,
my Column is called promos, and the stored values are W080045678, I want this value to be ignore since the 4th character is a 0 in the string.
What is the condition that I can add?
I have tried
AND promos <> '__'0%'
But no luck.

You are looking for NOT LIKE:
and promos not like '___0%'

Related

MSSQL - substring a value between other values [duplicate]

This question already has answers here:
Turning a Comma Separated string into individual rows
(16 answers)
Closed 2 years ago.
NOIDEHOB_NOIDE1_4321-123
i want to create a querie that extract the following values from the example above:
NOIDEHOB
NOIDE1
4321-123
I need to base the query on the sign _. The values NOIDEHOB, NOIDE1 and 4321-123 are dynamic and the length will vary. There will never be any other _ sign in the string.
Any suggestions?
You can use string_split():
select s.value
from string_split('NOIDEHOB_NOIDE1_4321-123', '_') s

Need to split string with repeated words in seperate row in oracle [duplicate]

This question already has answers here:
How to convert comma separated values to rows in oracle?
(6 answers)
Split function in oracle to comma separated values with automatic sequence
(10 answers)
Selecting delimited string as a table in Oracle sql
(4 answers)
Closed 5 years ago.
Hi i need help in splitting column into rows where ever repeated words are coming.
p_id Name
92222 MCD45-Quantum Red<REF ID="1552" TYPE="trademark"/>
TRI-TAG<REF ID="4684" TYPE="trademark"/>
i want to break into rows where TYPE="trademark" is coming
for ex :
p_id Name
92222 MCD45-Quantum Red<REF ID="1552" TYPE="trademark"/>
92222 TRI-TAG<REF ID="4684" TYPE="trademark"/>
It is dynamic and not known that how many times REF ID will come in column
string.for checking that i have used code :
regexp_count(name,'trademark') > 1
Can you please suggest how to do this.

SQL Server: select the first character that is not a digit 0-9 or / [duplicate]

This question already has answers here:
SQL to find first non-numeric character in a string
(3 answers)
Closed 5 years ago.
I have a table called Person, and a NVarChar column called Notes.
The Notes column has a lot of text in it, but always begins with a number of some kind, with /'s inserted throughout.
For example:
1/23 some text
45/678/9%*&^%$##
02/468/ some other text
I need to select the first character position that isn't a digit or /.
I don't care whether the position is 0-based or 1-based; I can accommodate that after the fact.
In this example, if I'm using 1-based character positions, the selection should produce the following:
5
9
8
So you're looking for an index that matches some sort of pattern, say a pattern index. If we're whimsical, we might abbreviate it to PATINDEX.
SELECT PATINDEX('%[^0-9/]%', Notes)
FROM Person

How to replace characters in SQL [duplicate]

This question already has an answer here:
Converting special character to plain text in oracle
(1 answer)
Closed 5 years ago.
I'm a new SQL user, and I'd like to know if there is a simple way of replacing non-English characters in Oracle SQl-developer. Let's Say, I want Hernán Nuñez to show up as Hernan Nunez, but without having to actually replace "Hernán" with "Hernan". What I need is to replace everything that contains "á" to the same thing, but with "a" instead, for example. Any suggestions?
US7ASCII will give you the right result. Example:
SELECT CONVERT('BESANÇON','US7ASCII')
FROM table;
CONVERT(
--------
BESANCON
1 row selected.

How to make column values more presentable [duplicate]

This question already has answers here:
How to get rightmost 10 places of a string in oracle
(5 answers)
Closed 8 years ago.
I have a table containing the following fields:
version
id
set_value
marker
I want to write a SELECT statement to query them. However, the values in the column marker are not easily readable. I would like to present a substring of that column. My question is how do I do this?
You can use this:
SELECT version,
id,
set_value,
SUBSTR(marker, 1, 10) AS marker
FROM ...
to select just the first ten characters of marker, and still have the resulting column be named "marker".
(See http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions169.htm.)
You can use the substr function.