15.查找employees表
问题:
查找employees表所有emp_no为奇数,且last_name不为Mary的员工信息,并按照hire_date逆序排列
CREATE TABLE employees
(
emp_no
int(11) NOT NULL,
birth_date
date NOT NULL,
first_name
varchar(14) NOT NULL,
last_name
varchar(16) NOT NULL,
gender
char(1) NOT NULL,
hire_date
date NOT NULL,
PRIMARY KEY (emp_no
));
解决:
思想:
1、员工号为奇数,则emp_no取余应为1
2、last_name不为Mary,用‘!=’表示
3.根据hire_date逆序排列,用desc
sql代码;
select *
from employees
where emp_no%2=1 and last_name<>'Marry'
order by hire_date desc;