Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql按升序排序,某些值的顺序不一致_Sql_Oracle_Sql Order By - Fatal编程技术网

Sql按升序排序,某些值的顺序不一致

Sql按升序排序,某些值的顺序不一致,sql,oracle,sql-order-by,Sql,Oracle,Sql Order By,我有一条SQL语句,它通过id按升序对表进行排序,但当我这样做时,表显示如下: c-10 c-12 c-12 c-24 c-5 c-6 c-80 c-800 c-8000 因为这表明顶部的少数和底部的少数是有序的,而不是其他部分。为什么会这样?因为我尝试了按表中的其他字段排序,它们看起来很好,所以只有这一列。您认为这可能是输入错误还是其他原因 非常感谢你的帮助 顺序正常,sql按词汇顺序对字符串排序 因为2(在c-24中)在5(在c-5中)之前,它是这样排序的 如果要按数字顺序对Sting进行

我有一条SQL语句,它通过id按升序对表进行排序,但当我这样做时,表显示如下:

c-10
c-12
c-12
c-24
c-5
c-6
c-80
c-800
c-8000
因为这表明顶部的少数和底部的少数是有序的,而不是其他部分。为什么会这样?因为我尝试了按表中的其他字段排序,它们看起来很好,所以只有这一列。您认为这可能是输入错误还是其他原因


非常感谢你的帮助

顺序正常,sql按词汇顺序对字符串排序

因为2(在c-24中)在5(在c-5中)之前,它是这样排序的

如果要按数字顺序对Sting进行排序,请在其前面加上零

c-0010 c-0012 c-0012 c-0024 c-0005 c-0006 c-0080 c-0800 c-8000将根据您的需要进行排序

select column
from your_table
order by to_number(regexp_substr(column, '\d+'))

为什么您认为这不符合顺序,请记住这是基于排序顺序,C-24低于C-5。如果你想要一个数字排序,你需要从表达式中删除C-我现在看到它是按字典顺序排序的,直到现在我才意识到这一点,因为我认为它会出现C-5,C-6,然后C-10 etcif a是从ID中删除-,会不会先对它进行排序,因为它的值是C后面的数字?