17,377
社区成员
发帖
与我相关
我的任务
分享
--1查询 SALGRADE 表中所有记录
select * from SALGRADE;
--2查询所有月薪在 1000 至 2000 之间的员工姓名、部门编号、月薪,按员工姓名排序
select ename,deptno,sal from emp where sal between 1000 and 2000 order by ename;
--3查询所有的工作种类
select job from emp group by job;
--4查询所有部门编号为 10 或 20 的员工信息,按部门编号降序排列
select * from emp where deptno=10 or deptno=20 order by deptno desc;
--5查询部门编号为 20,工作职位为 CLERK 的所有员工姓名及月薪
select ename,sal from emp where deptno=20 and job='CLERK';
--6查询所有姓名中包含 TH 或 LL 的员工姓名
select ename from emp where ename like '%TH%' or ename like '%LL%' ;
--7查询所有存在上级分管经理的员工信息
select * from emp where mgr<>0;
--8查询所有 1981 年录用的员工姓名、部门编号及录用日期,按录用日期排列
select ename,deptno,hiredate from emp where to_char(HIREDATE,'YYYY')=1981 order by hiredate;
--9查询所有员工的员工姓名、年薪(包含佣金),并按年薪升序排列。
select ename,sal*12+nvl(comm,0) yearsal from emp order by yearsal;
--10查询所有工作职位为 SALESMAN,并且月薪高于佣金的员工姓名、年薪(含佣金)、佣金,按月薪的降序排列
select ename,sal*12+nvl(comm,0),comm yearsal from emp where job='SALESMAN' and sal>comm order by yearsal desc;