#将员工的姓名按首字母排序,并写出姓名的长度

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要省略