Reputation: 3372
Is there a way I can find a certain character using LIKE
keyword?
For example, let's say I have the following values in COL1
:
1.75
5.50
5.67
I want to write a SQL statement that only returns values from COL1
where the second character AFTER the decimal is a zero (regardless of what the rest of the number says.)
Upvotes: 1
Views: 92
Reputation: 176214
Each value goes in this format: "#.##"
Then you could use wildcards %
and _
:
_
in pattern stands for (matches) any single character;%
matches any sequence of zero or more characters.Query:
SELECT *
FROM tab
WHERE col1 LIKE '%._0%';
Output:
╔══════╗
║ col1 ║
╠══════╣
║ 5.50 ║
╚══════╝
If values are only numbers (with two places only) you could use simple modulo division:
SELECT *
FROM tab
WHERE col1 % 0.1 = 0;
Upvotes: 1