zoukankan      html  css  js  c++  java
  • oracle截取字符串左右两边的字符数据,并用于排序

    截取一个字符串中-最后出现的左右两边的数据

    --截取左边

    SELECT reverse(substr(reverse(OBJBELONG),INSTR(reverse(OBJBELONG),'-') + 1)) FROM WF_TASK;

    --截取右边

    SELECT reverse(substr(reverse(OBJBELONG),1,INSTR(reverse(OBJBELONG),'-') - 1)) FROM WF_TASK;

    --以此来排序

    order by reverse(substr(reverse(OBJBELONG),INSTR(reverse(OBJBELONG),'-') + 1)) asc,TO_NUMBER(reverse(substr(reverse(OBJBELONG),1,INSTR(reverse(OBJBELONG),'-') - 1))) asc 

    --匹配正则查询

    SELECT
    *
    FROM
    arv_basinfo
    WHERE
    1 = 1
    AND reverse ( substr( reverse ( arvno ), INSTR( reverse ( arvno ), '-' ) + 0 ) ) = 'CSI-ZBZD-JY-2020-'
    AND TO_NUMBER(
    regexp_replace(
    reverse ( substr( reverse ( arvno ), 1, INSTR( reverse ( arvno ), '-' ) - 1 ) ),
    '[^0-9]',
    ''
    )
    ) >= 1
    AND TO_NUMBER(
    regexp_replace(
    reverse ( substr( reverse ( arvno ), 1, INSTR( reverse ( arvno ), '-' ) - 1 ) ),
    '[^0-9]',
    ''
    )
    ) <= 39500
    ORDER BY
    TO_NUMBER(
    regexp_replace(
    reverse ( substr( reverse ( arvno ), 1, INSTR( reverse ( arvno ), '-' ) - 1 ) ),
    '[^0-9]',
    ''
    )
    ) DESC

  • 相关阅读:
    Avira 去广告
    git 初步使用
    C语言中的取模符号讨论
    查看指定端口的进程
    fuck~disabled form
    编译器相关资源
    scheme 相关资源
    Binary search tree
    各种屏幕(包括手机)尺寸测试工具
    实现一个完整c++11编译器的认证
  • 原文地址:https://www.cnblogs.com/xuehu666/p/13952597.html
Copyright © 2011-2022 走看看