MySQL:过滤数据测试题

1.查询工资大于 12000 的员工姓名和工资

mysql>SELECT last_name,salary
      from employees
      where salary>12000;

2. 查询员工号为 176 的员工的姓名和部门号和年薪

mysql> select last_name as 姓名,department_id as 部门编号,ssalary*12*(1+IFNULL(commission_pct,0)) as 年薪
    -> from employees
    -> where employee_id=176

3.选择工资不在 5000 到 12000 的员工的姓名和工资

mysql> select last_name,salary
    -> from employees
    -> where
    -> salary not between 5000 and 12000;

4.选择在 20 或 50 号部门工作的员工姓名和部门号

mysql> #选择在20或50号部门工作的员工姓名和部门号
    -> select last_name,department_id
    -> from employees
    -> where department_id in (20,50);

5. d选择公司中没有管理者的员工姓名及 job_id

mysql> select last_name,job_id
    -> from employees
    -> where manager_id is null;

6. 选择公司中有奖金的员工姓名,工资和奖金级别

mysql> select last_name,salary,commission_pct
    -> from employees
    -> where commission_pct is not null;

7. 选择员工姓名的第三个字母是 a 的员工姓名

mysql> select last_name
    -> from employees
    -> where last_name like '__a%';

8. 选择姓名中有字母 a 和 e 的员工姓名

mysql> select last_name
    -> from employees
    -> where last_name like '%a%e%' or last_name like '%e%a%';

9. 显示出表 employees 表中 first_name 以 'e’结尾的员工信息

mysql> select * from
    -> employees
    -> where first_name like '%e';

10. 显示出表 employees 部门编号在 80-100 之间 的姓名、职位

mysql> select last_name 姓名,job_id
    -> from employees
    -> where department_id between 80 and 100;

11. 显示出表 employees 的 manager_id 是 100,101,110 的员工姓名、职位

mysql> select last_name,job_id
    -> from employees
    -> where manager_id in(100,101,110);
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值