I have a table emp. There is only one column in the table.
In that , there are only three rows in that column.
The value in the first row is 'A' and the value in the
second row is 'B' and the third row is 'C'. Now, my question
is ,

How will you write a select query to display the output as
B
C
A

Note: order by cannot be used coz it gives us output as CBA.
But the output should be BCA.

Answer Posted / ajitnayak

declare
type samp_type is table of VARCHAR2(20)
index by binary_integer;

table_type samp_type;

cursor c1 is
select Colum-Name from Table_name;

begin
open c1;

fetch c1 bulk collect into table_type;

close c1;

for i in reverse 1..4 loop
dbms_output.put_line(table_type(i));
end loop;
end;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is not equal to in oracle?

761


How would you go about verifying the network name that the local_listener is currently using?

1808


What is logical backup in oracle?

771


How translate command is different from replace?

740


Explain the use of control file?

866


How to divide query output into groups in oracle?

742


How to delete a user account in oracle?

744


What are the differences between date and timestamp in oracle?

779


Does oracle database need java?

735


I have a database backup file in .db (ext) form how to conver it into .dmp (ext.) for oracle database

1885


Can group functions be used in the order by clause in oracle?

764


What are group functions in oracle?

768


How can I introduce multiple conditions in like operator?

730


What is meant by recursive hints in oracle?

826


How to select all columns of all rows from a table in oracle?

776