A little question about the use of order by in oracle

 

There is a table A, with fields S_ID, NAME, and now there are 5 records in the table

S_ID    NAME
6 device 4 port 1 rate
8 device 2 port 1 rate
10 device 0 port 1 rate
7 Device 1 port 1 rate
9 Device 3 Port 1 Rate

 

When the query statement is "SELECT * FROM A", the result is as above.

 

The query statement is "SELECT * FROM A ORDER BY S_ID", the results are as follows

6 device 4 port 1 rate
7 Device 1 port 1 rate
8 device 2 port 1 rate
9 Device 3 Port 1 Rate
10 device 0 port 1 rate

 

The query statement is "SELECT * FROM A ORDER BY NAME", the results are as follows

10 device 0 port 1 rate
7 Device 1 port 1 rate
8 device 2 port 1 rate
9 Device 3 Port 1 Rate
6 device 4 port 1 rate

 

The query statement is "SELECT NAME AS S_ID FROM ORDER BY S_ID", the results are as follows

device 0 port 1 rate
Device 1 Port 1 Rate
Device 2 Port 1 Rate
Device 3 Port 1 Rate
Device 4 port 1 rate

 

You can see that S_ID is an alias identified as name, not a field in the table. Therefore, it can be inferred that order by is sorted according to the query results

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325346393&siteId=291194637