SELECT
LENGTH(last_name),SUBSTR(last_name,1,1) AS 首字符
FROM
employees
ORDER BY
首字符 ;
可直接字母排序
#给job_id分等级
SELECT
job_id,
CASE job_id
WHEN ‘AD_PRES‘ THEN ‘A‘
WHEN ‘ST_MAN‘ THEN ‘B‘
WHEN ‘IT_PROG‘ THEN ‘C‘
WHEN ‘SA_REP‘ THEN ‘D‘
WHEN ‘ST_CLERK‘ THEN ‘E‘
END
FROM
employees
当没有其他情况时,else要省略
原文:https://blog.51cto.com/14437184/2435971