shuffling of data [message #399166] |
Tue, 21 April 2009 00:15  |
gaikwadrachit
Messages: 33 Registered: June 2007 Location: mumbai
|
Member |
|
|
Hi
Can any one tell me how to shuffle data in a column.
data in a column can be varchar or number.
eg
Emp_no emp_name
123 robert
342 jack
6456 tom
3232 peter
454 caprio
I want an output like
Emp_no emp_name
123 borelr
342 jcak
6456 tmo
3232 teerp
454 paorio
|
|
|
|
|
|
|
|
|
|
|
Re: shuffling of data [message #399234 is a reply to message #399166] |
Tue, 21 April 2009 03:57   |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
You need to select each of the columns that you want to sort independently, along with a densely populated order column that lists the position in the list that each value should come at.
You then join the seperate queries on the Order column:with src as (select 123 empno, 'robert' ename from dual union all
select 342 ,'jack' from dual union all
select 6456 ,'tom' from dual union all
select 3232 ,'peter' from dual union all
select 454 ,'caprio' from dual)
select empno,ename
from (select empno,row_number() over (order by empno) empno_ord
from src) s1
,(select ename,row_number() over (order by ename) ename_ord
from src) s2
where s1.empno_ord = s2.ename_ord;
|
|
|
|
|
Re: shuffling of data [message #399292 is a reply to message #399166] |
Tue, 21 April 2009 08:10  |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
gaikwadrachit wrote on Tue, 21 April 2009 01:15 |
Emp_no emp_name
123 robert
454 caprio
I want an output like
Emp_no emp_name
123 borelr
454 paorio
|
Explain how the two rows for the input are related the the output.
|
|
|