当前位置:网站首页>20220728 sorting strings that are not pure numbers
20220728 sorting strings that are not pure numbers
2022-07-29 01:19:00 【Play with pigs】
Meet a need , You need to sort the displacement segments , These displacement sections are like this
Yes 2-2.5L、2.5-3L,3-5L…17L、13L such
The idea is , Take the first number of the string , To sort , If there is “-” Words , Then take “-” The numbers in front , without , Just take “L” Number before .
Need to use sql There are two formulas
SUBSTR( character string , Starting position , End position )-- Split string
INSTR( character string ,' A symbol ')-- Find the position of a symbol in the string
there SUBSTR The two split positions of both include this position , such as
SUBSTR('HELLO',0,3)-- have to 'HEL'
therefore , The code is
CASE WHEN INSTR(DISPLACEMENT_SEC,'-')>0
THEN SUBSTR(T.DISPLACEMENT_SEC,0,INSTR(DISPLACEMENT_SEC,'-')-1)
ELSE SUBSTR(T.DISPLACEMENT_SEC,0,INSTR(DISPLACEMENT_SEC,'L')-1) END AS DIS_SORT
Finally get DIS_SORT Use TO_NUMBER Just put it in order .
边栏推荐
- “index [hotel/jXLK5MTYTU-jO9WzJNob4w] already exists“
- js判断 数组/对象数组 1 是否包含数组/对象数组 2
- SystemVerilog-连接和复制运算符
- Canal real-time parsing MySQL binlog data practice
- Wechat campus bathroom reservation applet graduation design finished product (8) graduation design thesis template
- 如何在WordPress中创建一个自定义404错误页面
- Django使用MySQL数据库已经存在的数据表方法
- 指令重排、happens-before、as-if-serial
- [Commons lang3 topic] 004- numberutils topic
- 【mysql】字符串转int
猜你喜欢

大页内存原理及使用设置

Day2: 130 questions in three languages

State compression DP Mondrian's dream

Inftnews | yuanuniverse shopping experience will become a powerful tool to attract consumers

ACM SIGIR 2022 | 美团技术团队精选论文解读

Beginner's Guide to electronic bidding

mysql分表之后怎么平滑上线?

Hash table~

消费行业数字化升级成“刚需”,weiit新零售SaaS为企业赋能!

如何处理项目中的时间、范围和成本限制?
随机推荐
RHCE命令练习(一)
Oozie工作调度
FLV文件简介
Intel带你初识视觉识别--OpenVINO
How to implement the time impact analysis of the construction project?
Summary of process and thread knowledge points 1
【mysql】多指标历史累计去重问题
Wechat campus bathroom reservation for the finished product of applet graduation design (7) mid term inspection report
Flink SQL Hudi 实战
20220728-不纯为数字的字符串排序
Self made | a 16 bit RISC architecture CPU is self-made by hand
“index [hotel/jXLK5MTYTU-jO9WzJNob4w] already exists“
Y80. Chapter 4 Prometheus big factory monitoring system and practice -- Kube state metrics component introduction and monitoring extension (XI)
正则校验与时间格式化
【unity】将unity编辑c#配置为vscode
Spark 3.0 中七个必须知道的 SQL 性能优化
TextKit 自定义UILabel识别链接
vm options、program arguments、environment property
Tupu software appeared at the 2022 Fuzhou digital Expo to jointly create a new digital era
Seven marketing strategies of NFT project