How to display the column value adjacent to each other?

The general format of the query is :

   SELECT a.dnum, b.cnum
   FROM
   (select rownum num1,
    decode(mod(rownum,2),1,your_column_name) dnum
    from your_table_name ) a,
   (select rownum num2,
    decode(mod(rownum,2),0,your_column_name) cnum
    from your_table_name  ) b
    where (a.dnum is not null and b.cnum is not null)
    AND b.num2=a.num1+1
 

A particular example is :
   SELECT a.dnum, b.cnum
   FROM
   (select rownum num1,
    decode(mod(rownum,2),1,ename) dnum
   from emp ) a,
   (select rownum num2,
    decode(mod(rownum,2),0,ename) cnum
   from emp ) b
   where (a.dnum is not null and b.cnum is not null)
   AND b.num2=a.num1+1

Have a Oracle Question
Do you have an Oracle Question?

Oracle Books
Oracle Certification, Database Administration, SQL, Application, Programming Reference Books

Oracle Application
Oracle Application Hints and Tips

Oracle Home
Oracle Database, SQL, Application, Programming Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.