当前位置:网站首页>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 .
边栏推荐
- null == undefined
- Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
- 【JDBC Part 1】概述、获取连接、CRUD
- Win11如何解禁键盘?Win11解禁键盘的方法
- ByteDance senior engineer interview, easy to get started, fluent
- Jerry's about TWS pairing mode configuration [chapter]
- 应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
- Typescript TS basic knowledge type declaration
- Relationship between URL and URI
- How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
猜你喜欢

Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold

如何实现横版游戏中角色的移动控制

Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
![Restapi version control strategy [eolink translation]](/img/65/decbc158f467ab8c8923c5947af535.png)
Restapi version control strategy [eolink translation]

South China x99 platform chicken blood tutorial

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

cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘

How to realize the movement control of characters in horizontal game
![[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster](/img/b6/e5d525d9c7c28f6ef04c3f59b40eb3.png)
[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster

An in-depth understanding of fp/fn/precision/recall
随机推荐
[JDBC Part 1] overview, get connection, CRUD
Develop those things: go plus c.free to free memory, and what are the reasons for compilation errors?
你可曾迷茫?曾经的测试/开发程序员,懵懂的小菜C鸟升级......
Lingyun going to sea | saihe & Huawei cloud: jointly help the sustainable development of cross-border e-commerce industry
Jerry's about TWS pairing mode configuration [chapter]
Use partial derivatives to display normals in unity
嵌入式开发:如何为项目选择合适的RTOS?
Win11时间怎么显示星期几?Win11怎么显示今天周几?
648. Word replacement
Take the intersection of two sets
【colmap】稀疏重建转为MVSNet格式输入
[open source] Net ORM accessing Firebird database
[colmap] sparse reconstruction is converted to mvsnet format input
How to integrate Google APIs with Google's application system (1) -introduction to Google APIs
Talk about relational database and serverless
用语雀写文章了,功能真心强大!
如何实现横版游戏中角色的移动控制
DBSync新增对MongoDB、ES的支持
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?