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!

How to get only the different column data as output in a query

VimalPSNov 7 2018 — edited Nov 12 2018

Hi All,

There have a query which returns two rows as output.

select 'Orange' item1,'Rice' item2,'Keyboard' item3,'Mobile' item4,'Bike' item5,'Book' item6,'Pen' item7 from dual

union all

select 'Orange' item1,'' item2,'Keyboard' item3,'Mobile' item4,'Car' item5,'Book' item6,'Pencil' item7 from dual;

pastedImage_2.png

The requirement is, the output should only contain data which are different.ie

pastedImage_4.png

Is there a direct way to achieve this in sql query.

Valuable comments are really appreciated.

Thank You

Comments
Post Details
Added on Nov 7 2018
13 comments
1,985 views