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?
Answers were Sorted based on User's Feedback
Answer / nihar meher
select distinct greatest(source,destination),least(source,destination) from tablename;
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / sushma ajay
select source, destination, distance from(
select source,destination,lag(source) over (order by distance) oldsrc,distance
from traveldist)
where nvl(destination,'@') <> nvl(oldsrc,'@');
Is This Answer Correct ? | 5 Yes | 6 No |
Answer / 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 |
What is a trigger in sql?
what is mean by forward declaration and where we'll use it.
Cite the differences between execution of triggers and stored procedures?
How does a trigger work?
What is a data definition language?
Can we use views in stored procedure?
How many sql statements are used? Define them.
Fetch an entire row from the employees table for a specific employee ID:
How collections are improve the performance?
How does cross join work?
Does pl sql work in mysql?
Explain the difference between rename and alias?