 <p>The question is a little bit poor specified. </p> <blockquote> <p>order the result in asc or desc depending upon a column value.</p> </blockquote> <p>A column takes many values (as there are multiple rows).</p> <p>Now, <code>order by</code> clause use an expression and order rows upon it. That expression should be morphotropic(;))</p> <p>So, assuming stardard oracle's employee schema, managers are:</p> <pre><code>select * from emp e where exists (select emp_id from emp where e.id=emp.mgr_id) </code></pre> <p>An workaround query may be:</p> <pre><code>Select e.id, e.name, e.birth_date, case when (select count(*) from emp e where exists (select emp_id from emp where e.id=emp.mgr_id) ) --existence of manager &gt; 0 then birth_date - to_date('1-Jan-1000','dd-mon-yyyy') else to_date('1-Jan-1000','dd-mon-yyyy') - birth_date end as tricky_expression from emp A order by 4; </code></pre> <p>That exexpresion is the <code>case</code>; Using a constant(subquery that decides there are managers) it changes values from positive to negative, that is, change the order direction.</p> <p><strong>UPDATE:</strong> with the details in the comments:</p> <pre><code>select id, name, birth_date emp_type from ( Select id, name, birth_date, emp_type, case when cnt_mgr &gt; 0 then birth_date - to_date('1-Jan-1000','dd-mon-yyyy') else to_date('1-Jan-1000','dd-mon-yyyy') - birth_date end as tricky_expression from( Select e.id, e.name, e.birth_date, emp_type, count(case when emp_type='M' then 1 else 0 end) over() as mgr_count from emp A where your_conditions ) order by tricky_expression ) where rownum=1; </code></pre>