1.先判断 emp_no 的奇偶性,用 cash when 结合 mod() 给 emp_no 打标签,余数=0为偶数,否则为奇数,将此列命名为 label;
2.然后将上述表作为子查询表根据题目给定的条件 select 出相应字段;
select emp_no,birth_date,first_name,last_name,gender,hire_date from (select *, case when mod(emp_no,2)!=0 then "奇数" else "偶数" end label from employees) a where label="奇数" and last_name!='Mary' order by hire_date desc