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
Answer / nihar meher
select distinct greatest(source,destination),least(source,destination) from tablename;
Is This Answer Correct ? | 3 Yes | 1 No |
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 |
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 |
Why truncate is faster than delete?
what is rdbms? : Sql dba
What does <> sql mean?
What trigger means?
What is faster join or subquery?
What can you do with pl sql?
Explain correlated query work?
What are the parameter modes supported by pl/sql?
1 SELECT a.field1, b.field2, c.field3, d.field4 2 FROM atable a, atable b, ctable c, dtable d 3 ? 4 ORDER BY 1 What is the minimum number of joins that must be specified on line 3 in the sample code above to properly link the tables? Notice that the table "atable" is aliased twice: once as "a" and once as "b." 1. One join 2. Two joins 3. Three joins 4. Four joins 5. Five joins
Explain what is dbms?
select sal from emp group by sal
How many rows can sqlite handle?