I have a problem with my query when I tried to convert the varchar field to double (numeric). I have this sql expression:
SELECT fullName, CAST(totalBal as numeric(9,2) FROM client_info ORDER BY totalBal DESC
Actually, I want to display the values โโof totalBal in descending order. But since this field is in varchar, the result is sometimes erroneous. This is the result when I tried to execute a query using this statement:
SELECT fullName, totalBal FROM client_info ORDER BY totalBal DESC
Result set:

The sorting of totalBal is incorrect. So I decided to convert varchar to numeric so that it can be sorted perfectly. Any idea?
Jay marz
source share