SQL – ORDER BY无法正常工作?

SELECT test_column FROM test_table ORDER BY test_column给出了这个:
1   
12  
123  
2  
3

为什么不:

1
2
3
12
123

@JosePHPla你明白了,谢谢.如何对数字字符串进行排序?

解决方法

尝试
SELECT test_column 
FROM test_table 
ORDER BY cast(test_column as int)

但是您应该考虑将列类型更改为正确的列类型.

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...