当前位置:网站首页>SQL sorts string numbers
SQL sorts string numbers
2022-04-23 07:47:00 【Brother Bing】
background :
Because of the needs of the project , You need to sort string numbers
Method 1 :
-
principle : Sort strings with the same length first , Then according to the string ASCII Sort code .
-
SQL sentence :
SELECT transactionGmv6Months FROM company WHERE categoryId=127726077 ORDER BY LENGTH(transactionGmv6Months),transactionGmv6Months; -
Query results :

Method 2 :
- principle : Remove unnecessary characters from the string first , Then convert to numeric type for sorting 【 recommend 】.
- SQL sentence :
SELECT transactionGmv6Months FROM company WHERE categoryId=127726077 ORDER BY CONVERT(REPLACE(REPLACE(transactionGmv6Months,'+',''),',',''),SIGNED) DESC - Query results :

版权声明
本文为[Brother Bing]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230625585204.html
边栏推荐
猜你喜欢

js之预解析

【NLP笔记】CRF原理初探

Ogldev reading notes

SAP 导出Excel文件打开显示:“xxx“的文件格式和扩展名不匹配。文件可能已损坏或不安全。除非您信任其来源,否则请勿打开。是否仍要打开它?

Window10版MySQL设置远程访问权限后不起效果

SAP PI/PO功能运行状态监控检查

SAP pi / PO rfc2soap publishes RFC interface as WS example

ABAP 从CDS VIEW 发布OData Service示例

基于NLP的软件安全研究(二)

Simple random roll call lottery (written under JS)
随机推荐
将单行文字自动适应到目标矩形框内
斐波拉去动态规划
对js中argumens的简单理解
二叉树的深度
What are the total number of all courses of Mr. Tang Xiaoyang, who is very popular in CSDN (question mark)
Scrapy 修改爬虫结束时统计数据中的时间为当前系统时间
Understanding the Role of Individual Units in a Deep Neural Networks(了解各个卷积核在神经网络中的作用)
面经总结2
Mobile game performance optimization
取得所有点列表中的最大值GetMaxPoint
SAP DEBUG调试FOR IN、REDUCE等复杂的语句
js之函数的两种声明方式
Rethink | open the girl heart mode of station B and explore the design and implementation of APP skin changing mechanism
根据某一指定的表名、列名及列值来向前或向后N条查相关列值的SQL自定义标量值函数
系统与软件安全研究(三)
Preliminary configuration of OpenGL super Dictionary (freeglut, glew, gltools, GLUT)
C# 文本文件的查找及替换(WinForm)
SAP PI/PO功能运行状态监控检查
Configure NPM
MySQL8.0 安装/卸载 教程【Window10版】