oracle有关的命令1

  • 格式:doc
  • 大小:16.59 MB
  • 文档页数:7

1. 查询出工资大于1500的所有有雇员的信息

2. 查询每月可以拿到奖金的雇员的信息(不为空 IS NOT NULL)

3. 查询工资大于1500,并且可以拿到奖金的雇员的信息

4. 查询工资不大于1500,并且不能拿到奖金的雇员的信息(使用NOT 取反)

Select * from emp where sal<=1500 and comm is null;

5查询基本工资大于1500,小于3000的雇员信息(使用between and 包含了等于的内容)

Select * from emp where sal>1500 and sal<3000;

6.查询出1981年出生的雇员的信息(BETWEEN ‘1-1月 -81’ AND ‘31-12月 -81’)

Select * from emp where hiredate between ‘1-1月 -81 and‘31-12月 -81’;

7.查询出雇员编号是7369、7449、7521的雇员的详细信息(IN表示在什么范围,相反为NOT

IN)

Select * from emp where empno in (7369,7449,7521);

8.通配符%表示任意长度,_表示一个长度

9.查询名字中第二个字母是M的雇员信息(LIKE ‘_M%’)

Select * from emp where ename like ‘_M%’;

10.查询出名字中包含字母M的雇员信息

Select * from emp where ename like’%M%’;

11.查询81年出生的所有员工的信息(LIKE ‘%81%’)

Select * from emp where hiredate like ‘%81%’;

12.查询工资中带6的员工的信息(证明LIKE可以应用在数字上) Select * from emp where sal like ‘%6%’;

13.查询编号不是7369的员工信息(<> 和 !=)

Select * from emp where empno <> 7369;

1.工资有低到高进行排序(默认为ASC 升序排列)

Select * from emp

order by sal desc;

2.要求查询出员工的信息,查询的信息按照工资又高到低进行排序,如果工资相等,则按照雇佣日期由早到晚进行排序

Select * from emp order by sal desc,hiredate asc;

(1)显示10部门雇员进入公司的星期数

Select

round((sysdate-hiredate)/7) from dept where deptno = 10;

1、查出部门30中所有员工

Select

ename from emp where deptno = 30;

2、列出所有办事员的姓名,编号和部门编号

Select ename,empno,deptno from emp where job = ‘CLERK’;

3、找出奖金高于工资的员工

Select ename from emp where comm > sal;

4、找出奖金高于工资60%的员工

Select ename from emp where comm >(0.6*sal);

5、找出部门10中所有经理和部门20中所有办事员的详细资料

select * from emp where deptno = 10 and job = ‘MANAGER’ union select * from emp where

deptno =10 and job = ‘CLERK’ ;

6、即不是经理又不是办事员但工资大于或等于2000的员工的详细资料

7、找出所有拿奖金的员工的不同工作

Select distinct job from where comm is not null;

8、找出不拿奖金或者奖金低于100的员工的所有信息

Select * from emp where comm is null or comm <100;

9、找出每个月倒数第3天受雇的所有员工

Select ename from emp where hireday = (last_day(hireday )- 3) ;//这种方法不知道为什么错了

难道单行函数不能用在where里面