Q

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 first published in January 2006

Dig deeper on Oracle and SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

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.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close