Skip to Main Content

Breadcrumb

XMAS_TREE

The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.

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)

We're not taking comments currently, so please try again later if you want to add a comment.

Comments

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


More to Explore

SQL

The Oracle documentation contains a complete SQL reference.