Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

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

945


what is innodb? : Sql dba

1034


What do you mean by dbms? What are its different types?

952


What is sql engine in oracle?

930


What is a full join sql?

983


What is sqlerrm?

883


What are pl/sql packages?

1035


Does truncate release storage space?

1015


How do you update f as m and m as f from the below table testtable?

1792


What is a recursive stored procedure?

1098


how would you write a query to select all teams that won either 2, 4, 6 or 8 games? : Sql dba

1300


What are some predefined exceptions in pl/sql?

1067


What is the limitation on the block size of pl/sql?

938


what is “go” in t-sql? : Transact sql

1045


Why is sql important?

1027