(1) 查询emp表的雇员名称和工资
select ename,sal from emp;
(2) 查询雇员工资上浮20%的结果
select sal*1.2 from emp;
(3) 查询emp表中不同的部门编号
select distinct deptno from emp;
(4) 查询雇员姓名和工资,并按工资从小到大排序
select ename ,sal from emp order by sal asc;
(5) 查询雇员姓名和雇佣日期,并按雇佣日期排序,后雇佣的显示在前面
select ename,hiredate from emp order by hiredate desc;
(6) 查询工资大于等于3000的雇员姓名、职务和工资
select ename,job,sal from emp where sal>=3000;
(7) 查询1982年以后雇佣的雇员姓名和雇佣时间、
select ename,hiredate from emp where extract(year from hiredate)>1982;
(8) 查询姓名第二个字符为“A”的雇员信息
select * from emp where ename like‘_A%’;
(9) 统计各部门的最高工资,排除最高工资小于3000的部门
select deptno,max(sal) from emp where sal>=3000 group by deptno;
(10)按职务统计工资总和并根据工资总和排序
select job,sum(sal) from emp group by job order by sum(sal) desc;
(11)查询雇员的名称和所在的部门的编号和名称
select ename,emp.deptno,dname from emp,dept where emp.deptno = dept.deptno;
(12)查询工资大于3000的雇员的名称、工资和所在的部门名称
select ename,sal,dname from emp,dept where emp.deptno = dept.deptno and sal >3000;
(13)查询比scott工资高的雇员名字和工资
select ename,sal from emp where sal>(select sal from emp where ename='SCOTT');
(14)查询工资高于平均工资的雇员名字和工资
select ename,sal from emp where sal >(select avg(sal) from emp);
(15)查询工资低于任何一个“clerk”的工资的雇员信息
select * from emp where sal<(select min(sal) from emp where job = 'CLERK');
(16)查询职务和scott相同,比scott雇佣时间早的雇员信息
select * from emp where job = (select job from emp where ename='SCOTT') and hiredate<(select hiredate from emp where ename ='SCOTT');
(17)查询部门10和部门20的所有职务
select distinct job from emp where deptno = ‘20’ or deptno = ‘10’;
(18)查询部门10和部门20中是否有相同的职务和工资
select job sal from emp where deptno = ‘10’
intersect
select job sal from emp where deptno = ‘20’;
(19)查询10号部门出现而在20号部门没有出现的职务
select job from emp where deptno = '10' and job not in(select job from emp where deptno = '20');
select job from emp where deptno = 10
minus
select job from emp where deptno = 20
(20)查询各部门的平均工资、最高工资、最低工资和总工资列表,并按照总工资高低顺序排序
select deptno,max(sal),min(sal),sum(sal) from emp group by deptno;