Order by n...是什么意思?
程序员文章站
2022-07-12 23:10:38
...
For Example:
SQL> select * from test_tab order by 1;
COL_A COL_B
---------- ----------
A 1
A 2
B 2
B 3
C 4
D 1
D 12
D 121
D 12
9 rows selected
===============================================
SQL> select * from test_tab order by 2;
COL_A COL_B
---------- ----------
A 1
D 1
A 2
B 2
B 3
C 4
D 12
D 12
D 121
9 rows selected
===============================================
SQL> select * from test_tab order by 3;
select * from test_tab order by 3
ORA-01785: ORDER BY 项必须是 SELECT-list 表达式的数目
===============================================
以上看来:1表示第一个栏位, 2表示第二栏位, 依此类推
当表中只有2个栏位时, ORDER BY 3 就会出错
上一篇: 蓝桥杯:每日一题————Python