当前位置:网站首页>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 .
边栏推荐
- South China x99 platform chicken blood tutorial
- Code of "digital image processing principle and Practice (matlab version)" part2[easy to understand]
- Leetcode SQL first day
- Use partial derivatives to display normals in unity
- [colmap] sparse reconstruction is converted to mvsnet format input
- The function is really powerful!
- operator
- [open source] Net ORM accessing Firebird database
- Debugging and handling the problem of jamming for about 30s during SSH login
- Preparing for the interview and sharing experience
猜你喜欢

The strongest installation of the twin tower model, Google is playing "antique" again?

Open source OA development platform: contract management user manual

2022 how to evaluate and select low code development platforms?
Talk about relational database and serverless
![The maximum number of meetings you can attend [greedy + priority queue]](/img/f3/e8e939e0393efc404cc159d7d33364.png)
The maximum number of meetings you can attend [greedy + priority queue]

如何选择合适的自动化测试工具?

【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)

ByteDance Android interview, summary of knowledge points + analysis of interview questions

Paint basic graphics with custompaint
![[azure microservice service fabric] the service fabric cluster hangs up because the certificate expires (the upgrade cannot be completed, and the node is unavailable)](/img/35/1bb21c100980eb1075dbbcb922e181.png)
[azure microservice service fabric] the service fabric cluster hangs up because the certificate expires (the upgrade cannot be completed, and the node is unavailable)
随机推荐
DNS series (I): why does the updated DNS record not take effect?
应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
Programming mode - table driven programming
Anti climbing killer
NVR硬盤錄像機通過國標GB28181協議接入EasyCVR,設備通道信息不顯示是什麼原因?
客户案例|华律网,通过观测云大幅缩短故障定位时间
Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
Backup tidb cluster to persistent volume
PKPM 2020软件安装包下载及安装教程
Tsconfig of typescript TS basics JSON configuration options
Codemail auto collation code of visual studio plug-in
Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?
使用 CustomPaint 绘制基本图形
MIT6.S081-Lab9 FS [2021Fall]
Ad domain group policy management
It's worth seeing. Interview sites and interview skills
Reinforcement learning - learning notes 8 | Q-learning
Which financial products will yield high returns in 2022?
Latest Android advanced interview questions summary, Android interview questions and answers
Win11U盘不显示怎么办?Win11插U盘没反应的解决方法