Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Return only the columns with different values.

897305May 1 2013 — edited May 1 2013
Hi all,

I am trying to solve a seemingly trivial problem but can't seem to get any straight answer anywhere in any forum. Consider a single table with 5 columns and only two rows:
row_id           first_name         last_name        age            gender
1                    John                  doe               27             M
1                    Jane                  doe               27              F  
Assume there is no primary key or any other constraint. Also assume that there are only and only two rows in this table. So I basically need a query that, in the above set of rows, would return first_name and gender, as they are the only differing columns in the two rows, and also their values. Even if i can somehow get the column names that are differing that would be enough as I can easily access the values later on. Also it is important to remember that I may not know the column names of all the columns, so basically I somehow must utilize user_tab_columns in the process.

Any help appreciated.

Edited by: 894302 on May 1, 2013 10:35 AM
This post has been answered by Frank Kulash on May 1 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 29 2013
Added on May 1 2013
9 comments
429 views