ORDER BY关键字

ORDER BY 关键字用于对结果集进行排序。

ORDER BY 关键字默认按照升序对记录进行排序。如果需要按照降序对记录进行排序,您可以使用 DESC 关键字。

语法:

SELECT column_name,column_name FROM table_name ORDER BY column_name,column_name ASC|DESC;

示例:

    //从 "Websites" 表中选取所有网站,并按照 "alexa" 列排序:

SELECT * FROM Websites ORDER BY alexa;


    //从 "Websites" 表中选取所有网站,并按照 "alexa" 列降序排序:

SELECT * FROM Websites ORDER BY alexa DESC;

你可能感兴趣的:(SQL)