Connor and Chris will both be at AI World from October 12 to October 17 , the premier Oracle conference of 2025. If you're in Vegas, please come say Hi or pop into our sessions
Thanks for the question.
Asked: May 25, 2017 - 10:41 am UTC
Last updated: May 25, 2017 - 2:23 pm UTC
Version: Oracle12c
Viewed 1000+ times
CREATE TABLE t ( id int, src varchar2(6), dst varchar2(6) ); INSERT INTO t VALUES (1, 'Pune', 'Mumbai'); INSERT INTO t VALUES (2, 'Mumbai', 'Pune'); INSERT INTO t VALUES (3, 'Nashik', 'Goa'); INSERT INTO t VALUES (4, 'Goa', 'Nashik'); commit; select * from t; ID SRC DST 1 Pune Mumbai 2 Mumbai Pune 3 Nashik Goa 4 Goa Nashik select distinct least(src, dst) || '-' || greatest(src, dst) from t; LEAST(SRC,DST)||'-'||GREATEST(SRC,DST) Mumbai-Pune Goa-Nashik
Share and learn SQL and PL/SQL; free access to the latest version of Oracle Database!
Classes, workouts and quizzes on Oracle Database technologies. Expertise through exercise!