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 to change the order of columns in Oracle SQL Plus ?
How do you rename a table in sql?
What do you mean by rowid?
What are three advantages to using sql?
What is the difference between Union and Union all. Which is faster.
Explain what is a subquery ?
What is the difference between microsoft access and sql server?
What is a primary key example?
What is the difference between sql, mysql and sql server?
How do I view a view in sql?
GLOBAL TEMPORARY TABLE over Views in advantages insolving mutating error?
How many types of normalization are there?
What are the indexing methods?
What do you understand by exception handling in pl/sql?
what is the difference between $message and $$message? : Sql dba