The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
Thanks for the question, Hitesh.
Asked: May 07, 2018 - 2:40 pm UTC
Last updated: May 14, 2018 - 2:59 am UTC
Version: n/a
Viewed 1000+ times
Table name: City_distance From_city to_city distance ---------------------------------------- A B 100 B A 100 C B 200 C A 300 E F 700 F E 700
From_city to_city distance ---------------------------------------- A B 100 C B 200 C A 300 E F 700 or From_city to_city distance ---------------------------------------- B A 100 C B 200 C A 300 F E 700
SQL> create table t ( c1 varchar2(2), c2 varchar2(2), d int); Table created. SQL> insert into t values ('A','B', 100); 1 row created. SQL> insert into t values ('B','A', 100); 1 row created. SQL> insert into t values ('C','B', 200); 1 row created. SQL> insert into t values ('C','A', 300); 1 row created. SQL> insert into t values ('E','F', 700); 1 row created. SQL> insert into t values ('F','E', 700); 1 row created. SQL> select 2 distinct 3 greatest(c1,c2), 4 least(c1,c2), 5 d 6 from t; GR LE D -- -- ---------- F E 700 C A 300 C B 200 B A 100 4 rows selected.
The Oracle documentation contains a complete SQL reference.