Problem solve Get help with specific problems with your technologies, process and projects.

Display columns in rows

Please let me know if columns can be displayed row-wise instead of column-wise.

Please let me know if columns can be displayed row-wise instead of column-wise. For example, for the query:

select empno, ename from emp;

empno  ename
1234   Raj
1235   Christy

Can this be printed in the following format:

empno: 1234
ename: Raj
empno: 1235
ename: Christy

Yes, it's possible, but it would be an awful kluge to do it with just SQL.

Some things are better done in the database with SQL. For example, if you want to filter rows from a table, the best way to do this is with the WHERE clause. But some things are better done in the client tier, i.e., the application program or script. For example, to reformat the output from rows into columns as you have suggested, a simple array loop will do it, where the elements of the array are the columns of each row. This is a very simple programming task in any application or scripting language, but a real problem to do effectively with just SQL.

This was last published in January 2006

Dig Deeper on Oracle and SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.