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 do I pipe the output of one isql to another?
what is innodb? : Sql dba
What do you mean by dbms? What are its different types?
What is sql engine in oracle?
What is a full join sql?
What is sqlerrm?
What are pl/sql packages?
Does truncate release storage space?
How do you update f as m and m as f from the below table testtable?
What is a recursive stored procedure?
how would you write a query to select all teams that won either 2, 4, 6 or 8 games? : Sql dba
What are some predefined exceptions in pl/sql?
What is the limitation on the block size of pl/sql?
what is “go” in t-sql? : Transact sql
Why is sql important?