Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, vishnudas.

Asked: February 10, 2018 - 10:16 am UTC

Last updated: February 13, 2018 - 2:43 am UTC

Version: 11.2.0.1.0

Viewed 1000+ times

You Asked

hi there,
select substr('hellooracle',1,2)from dual;--> this will return 'he'
select substr('hellooracle',3,4)from dual;-->this will return 'll'
my question is i want to cut the entire string in a given order(for the above example it will like 1,2 2,4 4,6 etc)

is there any way to do this operation??

and Connor said...

SQL> select substr('hellooracle',level*2-1,2)
  2  from dual
  3  connect by level <= length('hellooracle')/2+1;

SUBSTR('
--------
he
ll
oo
ra
cl
e


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, February 13, 2018 - 4:57 am UTC


More to Explore

SQL

The Oracle documentation contains a complete SQL reference.