When I wrote the SQL statement today, I sorted the numbers relative to the string type. How to do it?
Need to be converted to numbers before sorting
+
directly¶String+0
eg:
select * from orders order by (mark+0) desc
CAST(value as type);
CONVERT(value, type);
Note:
The type
here can be:
DECIMAL
SIGNED
UNSIGNED
eg:
select * from orders order by CONVERT(mark,SIGNED) desc
select * from orders order by CAST(mark as SIGNED) desc