take one table is t1 and in that column name is f1
f1 column values are
200
5000
3000
7000
300
600
100
400
800
400
i want display the values asc and desc in a single output.
sample output is
f1.a
100
200
300
400
500
600
etc......
and f1.d is
5000
4000
3000
2000
1000
etc...
Answer Posted / venkyhulk1
if the output need to be displayed in two columns f1.a , f1.b
the querry will be
select a.f1 "f1.a", c.f1 "f1.b"
from (select rownum r1, f1 from t1) a,(select rownum r1,b.f1
f1 from (select f1 from t1 order by f1 desc) b) c
where a.r1=c.r1
hope this is the shortest querry that one can write in sql
to get this task done .
if u try it in other ways as shown above it will perform
catesian product which results in more rows than required .
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Whis is not false in primary key?
what are the different functions in sorting an array? : Sql dba
how to convert character strings to dates? : Sql dba
Why do we use partitions in sql?
Differentiate between sga and pga.
Why we use stored procedure instead of query?
what is column? : Sql dba
Name the operator which is used in the query for pattern matching?
who introduced sql?
how to drop an existing table in mysql? : Sql dba
Explain the uses of a database trigger?
What do you mean by “trigger” in sql?
How can I speed up sql query?
Write a query to find the names of users that begin with "um" in sql?
What are sql functions? Describe in brief different types of sql functions?