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 / deepak

select source, destination, distance from Distance_rcd where source>destination
union select destination, source, distance from Distance_rcd where source<destination

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is offset in sql query?

593


What is database white box testing and black box testing?

634


Define SQL and state the differences between SQL and other conventional programming Languages?

678


What is normalisation and its types?

543


How do I pipe the output of one isql to another?

530






What has stored procedures in sql and how we can use it?

561


What is a memo field?

522


How is a process of pl/sql compiled?

595


Why trigger is used in sql?

525


Why is normalization important?

534


What is the size of partition table?

550


what are the different tables present in mysql? : Sql dba

501


Can you have more than one key in a database?

506


What are the query optimization techniques?

535


How do you write a subquery?

517