Can Anyone help to suggest the query

source table:
Origin Destination Miles
Sydney Melbourne 1000
Perth Adelaide 3000
Canberra Melbounre 700
Melbourne Sydney 1000
Brisbane Sydney 1000
Perth Darwin 4000
Sydney Brisbane 1000
Duplicate routes are to be ignored so the output is
out put:
Origin Destination Miles
Sydney Melbourne 1000
Perth Adelaide 3000
Canberra Melbounre 700
Brisbane Sydney 1000
Perth Darwin 4000
Please suggest a select query / sub query with out using any subprograms or functions/pkgs to get the out put table.

You can try this:
select distinct
greatest(ORIGIN, DESTINATION) as "City a"
,least(ORIGIN, DESTINATION) as "City b"
, DISTANCE
from MY_TABLE;
But you have to be sure that columns ORIGIN, DESTINATION from MY_TABLE have "NOT NULL" contraints, otherwise you have to deal with null values somehow (e.g. with "nvl").

Similar Messages

Maybe you are looking for

  • No! Java 1.5 is all different!

    Ok I'm totally not impressed by the new version of java! Everything has like, changed! There's lots of new stuff we have to learn and I'm like, still learning java 1.4! Why did they have to change stuff? Java is like, totally difficult enough already

  • Doubt on Reports

    Hi gurus, I have one query with me,Please help me out this. I developed a report, In that I wrote so many select queries all are working fine.And also I wrote some error messages if the data is not selected. Here my doubt is if the data is not select

  • HT201263 i have forgotton the password on 4s and the phone is disabled. How to open it and get it working normally?

    i have forgotton the password on my iphone 4 s and now the phone is disabled. How do i get it working normally?

  • PO Updates in SRM

    Hello, I have a requirement for a report in SRM which should update the account assignment in SRM-PO with the new WBS Element / Fund. Now, I am little new to SRM programming. Could some one give me detailed steps as to what FMs do I need to use and h

  • ATV2 Video pixelated and audio skipping

    I don't think this is the same as the flickering issue or the frame dropping issue discussed by others. Thus, the new thread. When streaming videos (movies or TV shows) from itunes to the ATV2 the picture will get pixelated with the missing portions