Custom Sorting Function - of SQL Server(SQL Server 的自定义排序函数)
问题描述
我在 SQL Server 2005 中有一个列,它将版本号存储为我想要排序的字符串.我一直无法找到如何对此列进行排序,尽管我猜它是某种自定义函数或比较算法.
I have a column in SQL Server 2005 that stores a version number as a string that i would like to sort by. I have been unable to find out how to sort this column, although i am guessing it would be some kind of custom function or compare algorithm.
任何人都可以指出我从哪里开始的正确方向吗?我可能在谷歌上搜索错误的东西.
Can anyone point me in the right direction of where to start? I may be googling the wrong stuff.
干杯
崔斯
推荐答案
我会使用单独的 int 列(例如,如果您正在跟踪主要 + 次要版本,则使用 MajorCol + MinorCol)并运行类似
I'd use separate int columns (e.g. MajorCol + MinorCol if you are tracking major + minor versions) and run something like
order by MajorCol, MinorCol
在我的查询中.
这篇关于SQL Server 的自定义排序函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SQL Server 的自定义排序函数
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 更改自动增量起始编号? 2021-01-01
