Oracle sql order by with case statement
I am facing difficulty in understanding oracle(12c) sql order by clause with case statement. I have a table with the below data, SELECT DEPT_NO, DEPT_NAME FROM SORTNG_LOGIC; DEPT_NO DEPT_NAME ---------- -------------------- 1 FINANCE 2 ACCOUNT 3 HUMAN RESOURCE 4 AUDIT 5 TRAINING I am executing the below sql query for this table to add custom order, on oracle sql developer. SELECT DEPT_NO, DEPT_NAME FROM SORTNG_LOGIC ORDER BY ( CASE DEPT_NAME WHEN 'ACCOUNT' THEN '1' WHEN 'AUDIT' THEN '2' WHEN 'FINANCE' THEN '3' ELSE '4' END )DESC; This is giving the below result : DEPT_NO DEPT_NAME ---------- -