/*
语法:
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
SELECT T_TYPE,T_NAME FROM(SELECT 'C1' AS T_TYPE,'N2' AS T_NAME
UNION ALL
SELECT 'C1','N1'
UNION ALL
SELECT 'B2','N1'
UNION ALL
SELECT 'T2','N3'
UNION ALL
SELECT 'T1','N10'
UNION ALL
SELECT 'B1','N1'
) E
ORDER BY
CASE WHEN LEFT(T_TYPE,1)='C' THEN 1
WHEN LEFT(T_TYPE,1)='B' THEN 2
WHEN LEFT(T_TYPE,1)='T' THEN 3
END,
T_TYPE,
T_NAME
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)