Question
3
Replies
67
Views
Scotiabank
Posted: June 26, 2017
Last activity: June 28, 2017
Closed
How to sort a varchar as a numeric? Example: 1.2.1, 1.2.10,1.2.11,1.2.2,1.2.3,1.2.4,1.2.5,1.2.6,1.2.7,1.2.8,1.2.9
How to sort a varchar as a numeric? Example: 1.2.1, 1.2.10,1.2.11,1.2.2,1.2.3,1.2.4,1.2.5,1.2.6,1.2.7,1.2.8,1.2.9
I am expecting the order as 1.2.1,1.2.2,1.2.3,1.2.4,1.2.5,1.2.6,1.2.7,1.2.8,1.2.9,1.2.10,1.2.11.
If anyone has encountered this issue and has a solution, please do let me know.
Hi Sridhar,
Assuming you are doing it in Oracle DB, try to add RPAD with any value and make the entire string of fixed length. Then try to sort the result column keeping the entire query set in a sub query or view.