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?

Answers were Sorted based on User's Feedback



source destination distance chennai bangalore 500 bangalore chennai 500 hyd delhi 1000..

Answer / nihar meher

select distinct greatest(source,destination),least(source,destination) from tablename;

Is This Answer Correct ?    3 Yes 1 No

source destination distance chennai bangalore 500 bangalore chennai 500 hyd delhi 1000..

Answer / ajitnayak

select distinct source,destination,distance from dist_tab where source > destination
minus
select distinct source,destination,distance from dist_tab where source < destination

Is This Answer Correct ?    0 Yes 0 No

source destination distance chennai bangalore 500 bangalore chennai 500 hyd delhi 1000..

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

source destination distance chennai bangalore 500 bangalore chennai 500 hyd delhi 1000..

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

Post New Answer

More SQL PLSQL Interview Questions

What is a schema in sql?

1 Answers  


What is break?

0 Answers  


What is difference between stored procedures and application procedures?

0 Answers  


HOW TO APPEAR FOR ONLINE EXAMS OF SQL & PL/SQL? WHICH BOOKS WILL BE BETTER FOR REFERENCE TO QUALIFY THESE EXAMS? ARE THERE ANY MODEL PAPERS AVAILABLE IN THE MARKET ABOUT SQL & PLSQL?

2 Answers  


What is pragma exception and how, when, where us

5 Answers  


What is sqlservr exe?

0 Answers  


what is innodb? : Sql dba

0 Answers  


What is dense_rank in sql?

0 Answers  


What is online transaction processing (oltp)?

0 Answers  


explain advantages of innodb over myisam. : Sql dba

0 Answers  


What information is needed to connect sql*plus an oracle server?

0 Answers  


Can we group by two columns in sql?

0 Answers  


Categories