当前位置:网站首页>Remember that a development is encountered in the pit of origin string sorting
Remember that a development is encountered in the pit of origin string sorting
2022-07-07 22:17:00 【freelooppowter】
Briefly describe the situation , In the stored procedure, a field of string type is used as the sorting number of patient visits , The result is inexplicably found that the call is over 1 Called after the th 11、12 Wait for patients . User feedback may not be accurate , I added my own log , Copy the log quickly to observe . It turns out that the actual situation is like this , It's wrong to say , Start looking at the code , Fields used for analysis and sorting , After analysis, it is found that since this field is a string, the collation is a character by character comparison , Write a separate statement to test , Right enough .
WITH T AS
(SELECT '11' STR
FROM DUAL
UNION ALL
SELECT '2' STR FROM DUAL
UNION ALL
SELECT '3' STR FROM DUAL
UNION ALL
SELECT '21' STR FROM DUAL
UNION ALL
SELECT '30' STR FROM DUAL
UNION ALL
SELECT '1' STR FROM DUAL)
SELECT * FROM T ORDER BY STR;
The output is as follows :
1 1
2 11
3 2
4 21
5 3
6 30
Because this field will store Chinese characters , In the end use state The numeric part of the field and the fetch string is converted to a numeric value , And then sort it . as for
Take the numerical part , Using regular expressions
to_number(regexp_substr(nvl( Field a,0),'[0-9]+'))
Record the pit you encountered , It could be very simple , But easy to ignore . Be diligent in practice 、 Willing to record , Love to share .
边栏推荐
- 23. Merge K ascending linked lists -c language
- [open source] Net ORM accessing Firebird database
- Code of "digital image processing principle and Practice (matlab version)" part2[easy to understand]
- OpenGL configuration vs2019
- Validutil, "Rethinking the setting of semi supervised learning on graphs"
- 戴森官方直营店免费造型服务现已开放预约 先锋科技诠释护发造型理念,助力消费者解锁多元闪耀造型
- SAR影像质量评估
- L2:ZK-Rollup的现状,前景和痛点
- OpeGL personal notes - lights
- Develop those things: go plus c.free to free memory, and what are the reasons for compilation errors?
猜你喜欢
NVR硬盤錄像機通過國標GB28181協議接入EasyCVR,設備通道信息不顯示是什麼原因?
反爬通杀神器
The maximum number of meetings you can attend [greedy + priority queue]
[open source] Net ORM accessing Firebird database
PKPM 2020 software installation package download and installation tutorial
【JDBC Part 1】概述、获取连接、CRUD
双塔模型的最强出装,谷歌又开始玩起“老古董”了?
Time standard library
Embedded development: how to choose the right RTOS for the project?
Wechat official account oauth2.0 authorizes login and displays user information
随机推荐
Jerry's about TWS channel configuration [chapter]
PKPM 2020软件安装包下载及安装教程
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
Implementation method of data platform landing
三元表达式、各生成式、匿名函数
DBSync新增对MongoDB、ES的支持
Tupu digital twin coal mining system to create "hard power" of coal mining
Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve
PKPM 2020 software installation package download and installation tutorial
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
Tsconfig of typescript TS basics JSON configuration options
Oracle advanced (VI) Oracle expdp/impdp details
What if the win11u disk does not display? Solution to failure of win11 plug-in USB flash disk
L'enregistreur de disque dur NVR est connecté à easycvr par le Protocole GB 28181. Quelle est la raison pour laquelle l'information sur le canal de l'appareil n'est pas affichée?
怎样写一个增广矩阵到txt文件中
Dbsync adds support for mongodb and ES
【JDBC Part 1】概述、获取连接、CRUD
客户案例|华律网,通过观测云大幅缩短故障定位时间
SAR影像质量评估
[colmap] sparse reconstruction is converted to mvsnet format input