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.
Dig Deeper on Oracle and SQL
Related Q&A from Rudy Limeback
Read SQL expert Rudy Limeback's advice for counting combinations in a table with SQL's GROUP BY clausecontinue reading
Read an example of an SQL case expression from our SQL expert Rudy Limeback.continue reading
Read about the Mimer Validator, a tool used to verify your SQL code, in this tip from SQL expert Rudy Limeback.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.