SQL order by statement

About the Order by :

    order by statement to sort the result set according to the specified column, in ascending order by default.

    1. select field names from table where conditions order by field name 1 asc / desc, field name 2 asc (ascending, default) / desc (descending), .......

    2. select field names from table where field conditions order by ID asc / desc, field number asc / desc, ....... (field number starting from 1)

Finally, note that at the time of order by using EDITORIAL field will first execute , for example:

  SELECT sno, sname, sex, brithday, dno FROM student ORDER BY 4,5 DESC; // sentence of the fourth column (date column) in ascending order of priority (default), only the column with the same value (1983-10-04 ), the fifth column before descending order according to the statement.

  SELECT sno, sname, sex, brithday, dno FROM student ORDER BY 5,4 DESC; / * * column 5 ascending /

 

 

Guess you like

Origin www.cnblogs.com/fur-mat/p/11028819.html