-3

I need to get first two characters from first two words given in Oracle. Example follows:

example:

 string--> 'ganjikunta ramesh varma'

 output-->  ga ra
Littlefoot
  • 131,892
  • 15
  • 35
  • 57
  • 1
    https://stackoverflow.com/questions/34208563/plsql-best-way-to-split-string and then https://www.techonthenet.com/oracle/functions/substr.php – Dmitry Sokolov Nov 15 '19 at 16:51
  • it's very easy to do using for loop and substr like any other programming language.. question is that enough for you or do you need to implement it as part of a single sql query ? – j.i.t.h.e.s.h Nov 15 '19 at 16:56

1 Answers1

3

You can achieve it using combination of substr and instr. Try this:

Select substr(your_str, 1, 2) 
       || substr(your_str, instr(your_str, ' '), 3) -- 3 is used to fetch space and two charcters
From dual;

Cheers!!

Popeye
  • 35,427
  • 4
  • 10
  • 31