需要先转换成数字再进行排序

1.直接用加法

  字符串+0

eg:

  select * from orders order by (mark+0)  desc

2.使用函数

CAST(value as type);

CONVERT(value, type);

注:

  这里的type可以为:

    浮点数 : DECIMAL 
    整数 : SIGNED
    无符号整数 : UNSIGNED 

eg:

  select * from orders order by CONVERT(mark,SIGNED)  desc

  select * from orders order by CAST(mark as SIGNED)  desc

需要先转换成数字再进行排序

1.直接用加法

  字符串+0

eg:

  select * from orders order by (mark+0)  desc

2.使用函数

CAST(value as type);

CONVERT(value, type);

注:

  这里的type可以为:

    浮点数 : DECIMAL 
    整数 : SIGNED
    无符号整数 : UNSIGNED 

eg:

  select * from orders order by CONVERT(mark,SIGNED)  desc

  select * from orders order by CAST(mark as SIGNED)  desc

相关文章:

  • 2021-05-30
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2021-06-22
  • 2021-05-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-11-30
  • 2021-08-15
相关资源
相似解决方案