I have been trying to write a query where I need to find a salary
which does not end with ZERO
My Query :
select salary from employees where REGEXP_LIKE (Salary, '^(1|2|3|4|5|6|7|8|9)$');
Advertisement
Answer
I would just use the modulus here:
SELECT salary FROM employees WHERE MOD(salary, 10) != 0;
By definition, the modulus 10 returns the single (final) digit in the salary. Going this route avoids a costly conversion of the salary to a string, before another costly regex check.