Table Numeric Sort Order

I am needing to sort a table in numeric order (i.e 1,2,3,4,10,12,14 etc.) but it appears to be sorting my the first numeral only (1,10,12,14,2,3,4).

Unfortunately these values are stored as strings (Varchar) instead of a number or decimal. I’ve tried using .toNumber but this didn’t make any difference.

You could use a custom query action, and cast the varchar’s into integers:

select CAST(text_num AS UNSIGNED) as real_num from random
1 Like

Thanks @mebeingken I also managed to use

ORDER BY membership.membership_no * 1 ASC