- 显示出表employees中的全部job_id(不能重复)
select distinct job_id from employees;
- 显示出表employees的全部列,各个列之间用逗号连接,列头显示成OUT_PUT
select employee_id ||','|| last_name ||','|| salary "OUT_PUT" from employees;
- 查询工资大于12000的员工姓名和工资
select First_name,salary from employees where salary>12000;
- 查询员工号为176的员工的姓名和部门号
select first_name,department_id from employees where employee_id=176;
- 选择工资不在5000到12000的员工的姓名和工资
select first_name,salary from employees where salary not between 5000 and 12000;
- 选择雇用时间在1998-02-01到1998-05-01之间的员工姓名,job_id和雇用时间
select first_name,job_id,HIRE_DATE from employees where HIRE_DATE between '1-2月-07' and '1-5月-07';
- 选择在20或50号部门工作的员工姓名和部门号
select first_name,department_id from employees where department_id in(20,50);
- 选择在1994年雇用的员工的姓名和雇用时间
select first_name,hire_date from employees where hire_date like '% -94';
- 选择公司中没有管理者的员工姓名及job_id
select first_name,job_id from employees where manager_id is null;
- 选择公司中有奖金的员工姓名,工资和奖金级别
select first_name,salary,commission_pct from employees where commission_pct is not null;
- 选择员工姓名的第三个字母是a的员工姓名
select first_name from employees where first_name like '__a%';
- 选择姓名中有字母a和e的员工姓名
select first_name from employees where first_name like '%a%' and first_name like '%e%';
13.选择部门 30中的所有员工
select * from employees where department_id=30;
14.列出所有办事员(CLERK)的姓名、编号和部门编号
(在Oracle中是区分大小写的,所以此时要么将来 CLERK大写, 要么使用upper函数)
select ename,empno,deptno from employees where department_id=30;
- 找出佣金高于薪金的员工(comm.字段表示佣金或奖金)
select * from emp where comm > sal;
- 找出佣金高出奖金60%的员工
select * from emp where comm > sal*0.6;
- 查找部门10中所有经理(MANAGER)和部门20中所有办事员(CLERK)的详细资料
select * from emp where (deptno=10 and job='MANAGER') or (deptno=20 and job='CLERK');
- 查找部门10中所有经理(MANAGER)和部门20中所有办事员(CLERK),即不是经理又不是办事员,但薪金大于或等于2000的所有员工的详细资料
select * from emp where (deptno=10 and job='MANAGER') or (deptno=20 and job='CLERK') or (job not in ('MANAGER','CLERK') and sal>=2000);
- 找出收取佣金的员工的不同的工作。工作会出现重复,所以 DISTINCT 关键字消除重复的列
select distinct job from emp where comm is not null;
- 找出不收取佣金或收取的佣金低于100的员工
select job from emp where comm is null or comm<100;
网友评论