当前位置:网站首页>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 .
边栏推荐
- 强化学习-学习笔记9 | Multi-Step-TD-Target
- Relationship between URL and URI
- MIT6.S081-Lab9 FS [2021Fall]
- Solve the problem of uni in uni app Request sent a post request without response.
- Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
- Pdf document signature Guide
- OpeGL personal notes - lights
- Two kinds of updates lost and Solutions
- Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
- Preparing for the interview and sharing experience
猜你喜欢

648. Word replacement

NVR硬盤錄像機通過國標GB28181協議接入EasyCVR,設備通道信息不顯示是什麼原因?
![Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]](/img/14/1c8a70102c106f4631853ed73c4d82.png)
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]

operator

Google SEO external chain backlinks research tool recommendation

How to realize the movement control of characters in horizontal game

嵌入式开发:如何为项目选择合适的RTOS?

The latest Android interview collection, Android video extraction audio

应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设

Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda
随机推荐
三元表达式、各生成式、匿名函数
Use camunda to do workflow design and reject operations
Lingyun going to sea | saihe & Huawei cloud: jointly help the sustainable development of cross-border e-commerce industry
Embedded development: how to choose the right RTOS for the project?
How to realize the movement control of characters in horizontal game
Paint basic graphics with custompaint
建立自己的网站(18)
Jerry's configuration of TWS cross pairing [article]
The strongest installation of the twin tower model, Google is playing "antique" again?
Jerry's test box configuration channel [chapter]
23. Merge K ascending linked lists -c language
MIT6.S081-Lab9 FS [2021Fall]
Actual combat: sqlserver 2008 Extended event XML is converted to standard table format [easy to understand]
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
Meta force force meta universe system development fossage model
Jerry's key to initiate pairing [chapter]
An in-depth understanding of fp/fn/precision/recall
Use blocconsumer to build responsive components and monitor status at the same time
Jerry's fast pairing does not support canceling pairing [article]
Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve