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 / sumathy

Create table as 'f_order' with coulmn f1.

Run the following statement to get the above quesion's
results.

DECLARE @a INT, @b int
DECLARE @f1 CURSOR, @f2 CURSOR
Print 'Ascending '
SET @f1 = CURSOR FOR
SELECT f1
FROM f_order order by 1 asc
OPEN @f1
FETCH NEXT
FROM @f1 INTO @a
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @a
FETCH NEXT
FROM @f1 INTO @a
END
CLOSE @f1
Print 'Descending '
SET @f2 = CURSOR FOR
SELECT f1
FROM f_order order by 1 desc
OPEN @f2
FETCH NEXT
FROM @f2 INTO @b
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @b
FETCH NEXT
FROM @f2 INTO @b
END
CLOSE @f2
DEALLOCATE @f1
DEALLOCATE @f2

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What operating systems are supported by oracle sql developer?

518


How do you change a value in sql?

554


What is the difference among union, minus and intersect?

544


What are the uses of merge?

717


Explain the significance of the & and && operators in pl sql.

567






What is the difference between python and sql?

521


how many sql ddl commands are supported by 'mysql'? : Sql dba

523


How run sql*plus commands that are stored in a local file?

518


What is difference between pls_integer and integer?

516


What are the string functions in sql?

528


Is mariadb nosql?

581


what is the difference between primary key and unique key? : Sql dba

526


What is Collation Sensitivity ? What are the various type ?

497


What is difference between sql and excel?

513


explain the difference between myisam static and myisam dynamic. : Sql dba

513