mysql排序查询
/*
语法:
select 查询列表
from 表名
【where 筛选条件】
order by 排序的字段或表达式;
特点:
1、asc代表的是升序,可以省略
desc代表的是降序
2、order by子句可以支持 单个字段、别名、表达式、函数、多个字段
3、order by子句在查询语句的最后面,除了limit子句
*/
SELECT * FROM employees ORDER BY salary DESC;
SELECT *
FROM employees
WHERE department_id>=90
ORDER BY employee_id DESC;
SELECT ,salary 12 (1+IFNULL(commission_pct,0))
FROM employees
ORDER BY salary 12*(1+IFNULL(commission_pct,0)) DESC;
SELECT ,salary 12*(1+IFNULL(commission_pct,0)) 年薪
FROM employees
ORDER BY 年薪 ASC;
SELECT LENGTH(last_name),last_name
FROM employees
ORDER BY LENGTH(last_name) DESC;
SELECT *
FROM employees
ORDER BY salary DESC,employee_id ASC;