Go back
Home
  • database
    • WCDB
      • mybatis
        • mybatis中的常见的运算符和表达式
      • mysql错误处理
        • Warning: mysqli_connect(): (HY000/2002)
      • postgresql
        • macos安装和配置
        • postgresql
        • join 'on' 与 'where'
        • postgresql导入导出(pg_dump)
        • 列名、关键字冲突的情况
        • 字符串按数字类型排序
        • postgresql安装(macos)
        • 逗号分割的字典值转字典名称(postgresql)
      • oracle
        • 时间处理
        • 锁表以及处理方法
      • sql
        • sql 查询left join项的个数
        • 求排名
        • 记录值是否存在另一个表中

字符串按数字类型排序

November 16, 2018
database

SELECT month FROM month_record ORDER BY month

得到1 10 8 9 显然是不符合要求的

postgresql

SELECT month FROM month_record ORDER BY month::int

https://stackoverflow.com/questions/8502505/order-varchar-string-as-numeric

mysql

SELECT month FROM month_record ORDER BY month + 0

  • postgresql
  • mysql