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

Practice 1: Changes to data will only be allowed on tables during normal office hours of 8.45 in the morning until 5.30 in the afternoon, MONDAY through FRIDAY. A. Create a procedure called SECURE_DML that prevents the DML statement from executing outside of normal office hours, returning the message: “you may only make changes during normal office hours” b. Create a statement trigger on the PRODUCT table which calls the above procedure. c. Test it by inserting a new record in the PRODUCT table.

1 Answers   Tech Mahindra,


What is trigger in flip flop?

0 Answers  


Can we want to pass a parameter payroll_id to this external pl/sql function, how do we do it?

0 Answers  


Does normalization improve performance?

0 Answers  


Is oracel sql developer written in java?

0 Answers  


What is form and report?

0 Answers  


What are nested triggers ?

6 Answers   Amazon, Appeal Soft, IBM, Infosys, TCS,


What are crud methods?

0 Answers  


When can we use the where clause and the having clause?

0 Answers  


Can we join more than 2 tables in sql?

0 Answers  


How do you retrieve the last N records from a table?

10 Answers  


list out some tools through which we can draw e-r diagrams for mysql. : Sql dba

0 Answers  


Categories