1.查看该公司的员工分布在哪几个部门
select distinct deptno from emp;
2.查看每个部门有哪些岗位
select distinct deptno , job from emp order by deptno;
3.查询工资每月1600的员工姓名和工作岗位
select ename ,job,sal from emp where sal=1600;
4.查询姓名为SMITH的所有信息
select * from emp where ename = 'SMITH';
5.查询每月工资大于1500的员工姓名及薪资
select ename ,sal from emp where sal>1500;
select ename ,sal from emp where sal>1500 order by sal;
6.查询工资在2000到3000之间的职员信息
select ename,sal,job from emp where sal between 2000 and 3000 order by sal;
7.查询没有奖金的员工的信息 IS NULL
select ename,sal,job ,comm from emp where comm is null or comm=0;
8.查询有奖金的员工的信息 IS NOT NULL
select ename,sal,job ,comm from emp where comm is not null and comm!=0;
9.查询部门是30而且工资超过1300的员工信息
select ename , deptno , sal from emp where deptno = 30 and sal >1300;
10.查询工资为1300,1500,3000的员工的信息(使用or)
select ename , sal from emp where sal=1300 or sal = 1500 or sal = 3000;
11.查询工资为1300,1500,3000的员工的信息(使用in)
select ename , sal from emp where sal in(1300,1500,3000);
12.查询名字是A打头的员工信息
select ename from emp where ename like 'A%';
13.查询名字里边包含AR的员工的信息
select ename from emp where ename like '%AR%';
14.查询名字以D结尾的员工的信息
select ename from emp where ename like '%D';
(1)按照薪资从低到高的顺序查询所有员工信息
select ename ,sal from emp order by sal;
(2)查看30部门的员工按薪资从高到低
select ename , deptno ,sal from emp where deptno = 30 order by sal desc;
(3)查看员工信息按照部门编号从低到高,再按照薪资从高到低
select ename , deptno,sal from emp order by deptno asc ,sal desc;