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 / 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 |
Post New Answer View All Answers
How does pl sql work?
What is output spooling in sql*plus?
What are the different ways to optimize a sql query?
Does sql*plus have a pl/sql engine?
How run sql*plus commands that are stored in a local file?
What are secondary keys?
What is record variable?
What is scalar function in sql?
What is the command used to fetch the first 5 characters of a string?
What is the difference between mdf and ndf files?
What packages(if any) has oracle provided for use by developers?
How many aggregate functions are available there in sql?
What is sql lookup?
What is data types in sql?
Why coalesce is used in sql?