Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle - Order by column with NULL values in last position

I am using Order by for records sorting. I want to select NULL records at last position in every sorting. Eg.

ASC - {1,2,3,4,5,6,7,NULL,NULL,NULL} 
DESC - {7,6,5,4,3,2,1,NULL,NULL,NULL}

How to do this in Oracle query?

like image 535
Ramesh Avatar asked Oct 22 '25 08:10

Ramesh


1 Answers

Your order by clause should be as follows:

desc

order by <field_name> desc nulls last;

asc

order by <field_name> asc nulls last;
like image 173
Shann Avatar answered Oct 24 '25 22:10

Shann