-2

For Example - If I have a string as mentioned below :-

Summary: Start Volume (monthly) = 2 End Volume (monthly) = 0 Volume Reduction (year) = 13 Efficiency Gains = 100 Log: 09/13/2017

I just want to show the value of Volume Reduction in a column. What query should I write?

2 Answers2

0

Try this one

SELECT SUBSTR(COL,S1,INSTR(COL,' ',S1)-S1) X
FROM  (SELECT COL, INSTR( COL, 'Volume Reduction (year) = ',1)+LEN('Volume Reduction (year) = ') AS S1
       FROM (SELECT 'Summary: Start Volume (monthly) = 2 End Volume (monthly) = 0 Volume Reduction (year) = 13 Efficiency Gains = 100 Log: 09/13/2017' AS COL 
             FROM DUAL) A
        ) B;

Output:

X
13
etsa
  • 5,020
  • 1
  • 7
  • 18
0

Try this one :

DECLARE @DATA VARCHAR(256);
DECLARE @DATA1 VARCHAR(256);

SET @DATA = 'Summary: Start Volume (monthly) = 2 End Volume (monthly) = 0 Volume Reduction (year) = 13 Efficiency Gains = 100 Log: 09/13/2017'

SELECT @DATA1 = RIGHT(@DATA,LEN(@DATA)-CHARINDEX(' 13',@DATA))

SELECT SUBSTRING(@DATA1, PATINDEX('%[1-9]%', @DATA1), LEN(120)) AS DATA
Yogesh Sharma
  • 49,870
  • 5
  • 26
  • 52