source destination distance
chennai bangalore 500
bangalore chennai 500
hyd delhi 1000
delhi hyd 1000
bangalore hyd 800

Here chennai to bangalore and bangalore to chennai is same distance. and hyd and delhi also same criteria.
Based on the distance i want to display only one row using sql query?

Answer Posted / nihar meher

select distinct greatest(source,destination),least(source,destination) from tablename;

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sql profiler in oracle?

558


What is before and after trigger?

517


What is scalar function in sql?

527


Why is partition used in sql?

546


How many types of indexes are there in sql?

535






What is primary key and foreign key?

531


What is a .db file?

536


What are the different type of joins in sql?

540


What are variables in pl sql?

556


What are the main features of cursor?

626


What is a record in pl/sql?

547


What is transaction control language (tcl)?

634


What is native sql query?

546


How does index help in query performance?

559


What is information schema in sql?

574