Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

to_number function with trim

AQHOct 11 2018 — edited Oct 11 2018
with condition to_number(trim(substr(val, instr(val,':')+1))) BETWEEN 0 AND -2.00 i am unable to get data, how to resolve please advice.

WITH data

     AS (SELECT 1 cde, 'sph: -1.25' val FROM DUAL

         UNION ALL

         SELECT 2, 'abc:  -2.50' FROM DUAL

         UNION ALL

         SELECT 3, 'sph1:  -0.75' FROM DUAL

         UNION ALL

         SELECT 4, 'sph2: -2.25' FROM DUAL

         UNION ALL

         SELECT 4, 'sph2: 0' FROM DUAL

         UNION ALL

         SELECT 4, 'sph2: -3.00' FROM DUAL

         UNION ALL

         SELECT 4, 'sph2: -1.75' FROM DUAL

          UNION ALL

         SELECT 4, 'sph2: -2.00' FROM DUAL)

SELECT trim(substr(val, instr(val,':')+1)) value , trim(substr(val, instr(val,':')+1)) "require range"

FROM data

where to_number(trim(substr(val, instr(val,':')+1))) BETWEEN 0 AND -2.00;

This post has been answered by Saubhik on Oct 11 2018
Jump to Answer
Comments
Post Details
Added on Oct 11 2018
3 comments
754 views