Hi guys
I am trying to figure out a method to order a result returned by a query using decode with the order by clause
select empno, ename from scott.emp order by decode(:p_sort_by,'NO',empno,'NAME',ename);
The above query executes without any issues when I supply 'NO', however when 'NAME' is supplied, I get an error "Invalid number", I am curious to know what is happening. Please help me to understand the reasons behind the error. Instead of absolute column names, I tried to use 1,2. The same error was when tried to execute the query.
regards,
rajesh