I am struggling with a query in Oracle SQL, wanting to get some timings from some text stored in Oracle db.
Table : kde_test (myString varchar(50)) Table contents (3 records): 'task1 - 6m' 'task2 - 66m' 'task3 - 666m'
I would like to get only the interesting part of the line, being timings, so I would like to get the results only "6", "66" and "666".
I looked for this forum a bit, and in the end I got up with this question, but it seems that I do not fully understand it, since the results that it returns are as follows: 6m 66m 666m
select CASE WHEN myString like 'task1%' THEN substr(myString,9,INSTR(myString,'m',1,1)-1) WHEN myString like 'task2%' THEN substr(myString,9,INSTR(myString,'m',1,1)-1) WHEN myString like 'task3%' THEN substr(myString,9,INSTR(myString,'m',1,1)-1) END from kde_test where myString like 'task%'
EDIT:
Since some solutions (thanks already for a quick answer) take into account specific values ββ(for example, all 3 entries ending in "6m"), it may be best to consider the values:
Table contents (3 records): 'task1 - 6m' 'task2 - 58m' 'task3 - 123m'