Home » SQL & PL/SQL » SQL & PL/SQL » Columns values into rows
Columns values into rows [message #609231] Tue, 04 March 2014 04:31 Go to next message
msinha8
Messages: 43
Registered: March 2014
Location: Hyderbad
Member
Hello All,

I got some of values in the one column as a string
and I would like to get every of this values into the row.

For instance:
COLUMN
ABC

And result should be:
COLUMN
A
B
C


Does anybody help me on this ?

Thanks a lot

Regards
Re: Columns values into rows [message #609232 is a reply to message #609231] Tue, 04 March 2014 04:34 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
See this thread: http://www.orafaq.com/forum/t/191756/
Re: Columns values into rows [message #609235 is a reply to message #609232] Tue, 04 March 2014 05:18 Go to previous messageGo to next message
msinha8
Messages: 43
Registered: March 2014
Location: Hyderbad
Member
Thanks for ypur answer, but in my case i don't have any delimiter between my column values,whereas in referenced thread we have.


Regards
Re: Columns values into rows [message #609236 is a reply to message #609235] Tue, 04 March 2014 05:41 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If there's no delimiter, how do you know how to distinguish these values? I suppose that your columns don't really contain ABC but something like Littlefootbigfoot. What is desired result based on such a value?
Re: Columns values into rows [message #609239 is a reply to message #609235] Tue, 04 March 2014 05:52 Go to previous message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

SQL> with t as (
  2    select 'ABC' val from dual
  3    union all
  4    select 'Michel' from dual
  5    )
  6  select val, substr(val, column_value, 1) letter
  7  from t,
  8       TABLE(CAST(MULTISET(SELECT LEVEL FROM DUAL CONNECT BY LEVEL <= LENGTH(val))
  9                  AS SYS.odcivarchar2list))
 10  order by val, column_value
 11  /
VAL    L
------ -
ABC    A
ABC    B
ABC    C
Michel M
Michel i
Michel c
Michel h
Michel e
Michel l


Previous Topic: Locked Stats
Next Topic: Dynamic Column Generation
Goto Forum:
  


Current Time: Fri Apr 19 20:43:50 CDT 2024