对于int
order by t.type
改为
order by cast(t.type as integer)
对于double
改为
order by CONVERT(t.type,DECIMAL)
或
order by (t.type+0)
本文介绍如何在SQL中针对不同数据类型的字段进行正确排序的方法。包括将int类型通过cast转换为整数排序,以及double类型使用CONVERT转换为DECIMAL类型或直接加0实现数值排序。
对于int
order by t.type
改为
order by cast(t.type as integer)
对于double
改为
order by CONVERT(t.type,DECIMAL)
或
order by (t.type+0)
625

被折叠的 条评论
为什么被折叠?