当前位置:网站首页>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 .
边栏推荐
- The whole network "chases" Zhong Xuegao
- 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?
- 海外代理推荐
- Index summary (assault version)
- How polardb-x does distributed database hotspot analysis
- Two kinds of updates lost and Solutions
- Time standard library
- Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
- Cv2.resize function reports an error: error: (-215:assertion failed) func= 0 in function ‘cv::hal::resize‘
- L2: current situation, prospects and pain points of ZK Rollup
猜你喜欢
![Restapi version control strategy [eolink translation]](/img/65/decbc158f467ab8c8923c5947af535.png)
Restapi version control strategy [eolink translation]

How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525

海外代理推荐

Validutil, "Rethinking the setting of semi supervised learning on graphs"
![[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process](/img/80/11c2b539c217ecd6ba55668d3e71e9.png)
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process

How to make agile digital transformation strategy for manufacturing enterprises

How does win11 unblock the keyboard? Method of unlocking keyboard in win11

Reinforcement learning - learning notes 9 | multi step TD target

Win11时间怎么显示星期几?Win11怎么显示今天周几?
![[advanced MySQL] index details (I): index data page structure](/img/e7/fe4591a721a71c3c38d6e4448af6af.png)
[advanced MySQL] index details (I): index data page structure
随机推荐
Leetcode SQL first day
Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
Use br to recover backup data on azure blob storage
An in-depth understanding of fp/fn/precision/recall
Which futures company is the safest to open a futures account?
The essence of analog Servlet
Programming mode - table driven programming
L2:ZK-Rollup的现状,前景和痛点
OpenGL job - texture
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
Paint basic graphics with custompaint
Typescript TS basic knowledge type declaration
[azure microservice service fabric] the service fabric cluster hangs up because the certificate expires (the upgrade cannot be completed, and the node is unavailable)
DBSync新增对MongoDB、ES的支持
Jerry's key to initiate pairing [chapter]
Cv2.resize function reports an error: error: (-215:assertion failed) func= 0 in function ‘cv::hal::resize‘
Backup tidb cluster to persistent volume