• SQL 对汉字、字母、特殊符号进行分开排序


    select *
    from 表名
    order by
    case when unicode(left(字段, 1)) between 19968 And 40869 then 0
    when unicode(left(字段, 1)) between 97 And 122 or unicode(left(字段, 1)) between 65 And 90 then 1
    else 2 end,
    customer asc

    原因:根据unicode编码范围:

    --汉字:[0x4e00,0x9fa5](e79fa5e98193e59b9ee7ad9431333365643464或十进制[19968,40869])
    --数字:[0x30,0x39](或十进制[48, 57])
    --小写字母:[0x61,0x7a](或十进制[97, 122])
    --大写字母:[0x41,0x5a](或十进制[65, 90])
    判断第一个字母的范围,然后就行排序
  • 相关阅读:
    JavaWeb
    Network
    JavaWeb
    Maven
    IDEA
    Maven
    Network
    JavaWeb
    JavaWeb
    JavaWeb
  • 原文地址:https://www.cnblogs.com/fuyouqiang/p/12896376.html
Copyright © 2020-2023  润新知