Vishal5364 February 2016

How to order data in oracle select query without using order by

I am pretty new to Oracle and came across this question during an interview, which I cannot answer

Display the data in order without using ORDER BY, both ASCENDING and DESCENDING.

Is there any way to do this in Oracle ?

Answers


Wernfried Domscheit February 2016

Under some circumstances you don't need an ORDER BY clause.

Let's say you have table EMP with an index on column EMP_ID. Such query does not require an ORDER BY clause the result will be ordered automatically by EMP_ID:

SELECT *
FROM EMP
WHERE EMP_ID > 10;

However, you should not rely on that. In some conditions Oracle may behave different.

Post Status

Asked in February 2016
Viewed 2,092 times
Voted 9
Answered 1 times

Search




Leave an answer