此题中需要在select里写if语句进行判断,我们可以用sql中的if来实现,if函数中有三个参数:条件,值1,值2。
如果条件满足就取值一,不满足就取值2。
另,order by 默认从小到大排序。
# Write your MySQL query statement below
select
employee_id,
if(
employee_id&1 and name not like 'M%',
salary,
0
) as bonus
from
Employees
order by
employee_id