Oracle emp表操作

select * from emp;

/*1.选择部门30中的所有职工*/
select * 
  from emp
    where deptno = 30;
   
/*2.列出所有业务员(CLERK)的姓名,编号,和部门编号*/   
select ename,empno,deptno
  from emp
    where job = 'CLERK';
    
/*3.找出奖金高于薪金的员工*/
select *
  from emp
    where comm > sal;
    
/*4.找出奖金高于薪金的60%的员工*/
select *
  from emp
    where comm > sal * 0.6;
    
/*5.找出部门10中所有经理(MANAGER)和部门20中所有业务员(CLERK)的详细资料*/
select *
  from emp
    where deptno = 10 and job = 'MANAGER' or deptno = 20 and job = 'CLERK';
    
/*6.找出部门10中所有经理(MANAGER),部门20中所有业务员(CLERK),既不是经理又不是业务员但其薪水大于等于2000的所有员工的详细资料*/
select *
  from emp
    where deptno = 10 and job = 'MANAGER' or deptno = 20 and job = 'CLERK'
         or deptno in('10','20') and job != 'MANAGER' and  job !='CLERK' and sal >=2000;
         
/*7.找出收取奖金的员工的不同工作*/
select distinct job
  from emp
    where comm is not null;
    
/*8.找出不收取奖金或收取的奖金低于100的员工*/
select *
  from emp
    where comm is null or comm < 100;
    
/*9.显示正好为5个字符的员工姓名*/
select ename
  from emp
    where ename like '_____';
    
/*10.显示带有”R”的员工姓名*/
select ename
  from emp
    where ename like '%R%';
    
/*11.显示员工的详细资料,按姓名由大到小排序*/
select *
  from emp
    order by ename desc;
    
 /*12.显示所有员工的姓名,工作和薪金,按工作降序排列,若工作相同则按薪金升序排序*/
select ename,job,sal
  from emp
    order by job desc,sal asc;
    
/*13.显示姓名中任意位置包含“A”的所有员工姓名*/
select *
  from emp
    where ename like '%A%';

你可能感兴趣的:(Oracle)