AllExperts > Oracle 
Search      
Oracle
Volunteer
Answers to thousands of questions
 Home · More Oracle Questions · Answer Library  · Encyclopedia ·
More Oracle Answers
Question Library

Ask a question about Oracle
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Elliot Mak
Expertise
I can answer questions with regarding to Oracle DB (8i, 9i, 10g) installation, configuration, administration, Data Guard, SQL, and PL/SQL (Procedures, triggers, functions).

Experience
I am an Oracle DBA, Senior PA, Project Manager, and Data Architect with 10 years of experience.

Education/Credentials
BS in MIS

 
   

You are here:  Experts > Computing/Technology > Oracle > Oracle > Making Data as Column Names for View

Oracle - Making Data as Column Names for View


Expert: Elliot Mak - 5/15/2009

Question
Good day Sir!
How do I create a view where the columns are based on data in the table?Is that possible? For example I have an audit table:
a_logno varchar(10)
a_eventid varchar(10)
a_datetime date
a_userid varchar(10)

say the values for a_eventid are A, B, C
and i want to create a view that will look like this:
a_logno varchar(10)
A datetime
B datetime
C datetime
and the contents of columns A,B,C are the datetime corresponding to the events.
Is this possible Sir?
Would really appreciate your help. Thanks very much!

Answer
Good day Vee,

I apologize for the late reply.  It is currently a long weekend here in Canada and I just happened to check my email.

To answer your question, it looks like you want to transpose the row to column.  With Oracle, you can use the following

Here is an example to help you to do that
http://www.dba-oracle.com/t_converting_rows_columns.htm
http://www.oracle.com/technology/oramag/code/tips2004/050304.html

Tom Kyte also had a thread to talk about another way to do that
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:124812348063

Hope it helps.  Let me know you have difficulties in getting this works.

Cheers
Elliot

Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.