Bo's Oracle Station

查看: 2042|回复: 0

课程第12次(2017-03-20星期一)

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2017-3-21 09:38:16 | 显示全部楼层 |阅读模式
上完1Z0-051第5章:组函数和分组
上完1Z0-051第6章:表连接
进行1Z0-051第7章:子查询和关联子查询
1Z0-051共12章(上完7章),1Z0-052共19章(上完3章),1Z0-053共21章(上完0章)
总共上完全部52章中的10章

  1. select  count(e.commission_pct) from employees  e;



  2. select  sum(e.commission_pct)/count(e.commission_pct)
  3. from employees e;

  4. select  avg(e.commission_pct)
  5.   from employees e;
  6.   
  7.   SELECT AVG(NVL(commission_pct, 0))
  8. FROM   employees;

  9. select  sum(e.commission_pct)/count(*)
  10. from employees e;
  11. ----
  12. SELECT   department_id, manager_id, AVG(salary)
  13. FROM     employees
  14. GROUP BY department_id , manager_id
  15. order by 1,2;

  16. ---
  17. select  * from employees where employee_id=178;

  18. ---

  19. SELECT   department_id , AVG(salary) a
  20. FROM     employees
  21. where department_id  <70
  22. GROUP BY department_id
  23. having    AVG(salary) > 8000
  24. ;
  25. ---

  26. select  department_id, job_id , avg(salary)
  27.   from employees
  28.   group by rollup (department_id, job_id);
  29.   


  30. select  department_id, job_id , avg(salary)
  31.   from employees
  32.   group by cube (department_id, job_id);
  33.   
  34.   ----
  35.   
  36.   select e.employee_id, d.department_name, d.department_id
  37.     from employees e , departments d
  38.     where e.department_id=d.department_id;
  39.     ---
  40.     select e.employee_id, d.department_name, department_id
  41.     from employees e    join departments d
  42.     using ( department_id);
  43.    
  44.     ---
  45.       select e.employee_id, d.department_name, e.department_id
  46.     from employees e  join departments d
  47.     on ( e.department_id=d.department_id) ;
  48.    
  49.     ---
  50.    
  51.      select e.employee_id, d.department_name, department_id
  52.     from employees e  natural   join departments d;
  53.    
  54.     select  * from departments;
  55.     ---
  56.       select e.employee_id, d.department_name, d.department_id
  57.     from employees e , departments d
  58.     where e.department_id=d.department_id  
  59.      and e.manager_id=d.manager_id;
  60.      
  61.      ---
  62.      SELECT employee_id, city, department_name
  63. FROM   employees e
  64. JOIN   departments d
  65. ON     (d.department_id = e.department_id )
  66. JOIN   locations l
  67. ON    ( d.location_id = l.location_id)
  68. where l.city='Southlake';

  69. ---
  70.    SELECT employee_id, city, department_name
  71. FROM   employees e, departments d, locations l
  72. where d.department_id = e.department_id and
  73.   d.location_id = l.location_id
  74.   and l.city='Southlake';
  75.   
  76.   ---
  77.   
  78. SELECT worker.last_name emp, manager.last_name mgr
  79. FROM   employees worker , employees manager
  80. where    worker.manager_id = manager.employee_id;
  81. ---

  82. SELECT e.last_name, e.salary, j.grade_level
  83. FROM   employees e , job_grades j
  84. where   e.salary
  85.        BETWEEN j.lowest_sal AND j.highest_sal;
  86.       
  87.        ---
  88.       
  89.        select  e.employee_id ,e.last_name  ,d.department_name
  90.          from employees  e , departments d
  91.          where e.department_id =d.department_id (+);
  92.   
  93. ----

  94.          
  95.          select  e.employee_id ,e.last_name  ,d.department_name
  96.           from employees  e  left outer join departments d
  97.           on (e.department_id  =d.department_id);
  98.          
  99.              select  e.employee_id ,e.last_name  ,d.department_name
  100.           from employees  e  left outer join departments d
  101.           using (department_id) ;
  102.          
  103.          
  104.                   select  e.employee_id ,e.last_name  ,d.department_name
  105.           from  departments d  right outer join  employees  e
  106.           on (e.department_id  =d.department_id);
  107.          
  108.               select  e.employee_id ,e.last_name  ,d.department_name
  109.           from   departments d      right  outer join  employees  e
  110.           using (department_id) ;
  111.           ----
  112.           select  * from departments ;

  113.        select  e.employee_id ,e.last_name  ,d.department_name
  114.          from employees  e , departments d
  115.          where e.department_id (+) =d.department_id ;
  116.          
  117.          select  e.employee_id ,e.last_name  ,d.department_name
  118.          from employees  e   right outer join  departments d
  119.          on (e.department_id =d.department_id);
  120.          
  121.             select  e.employee_id ,e.last_name  ,d.department_name
  122.          from employees  e   right outer join  departments d
  123.          using (department_id );
  124.          
  125.           select  e.employee_id ,e.last_name  ,d.department_name
  126.          from departments d     left outer join  employees  e   
  127.          on (e.department_id =d.department_id);
  128.          
  129.             select  e.employee_id ,e.last_name  ,d.department_name
  130.          from     departments d   left  outer join  employees  e
  131.          using (department_id );
  132.          
  133.          
  134.          
  135.          
  136.          
  137.          ---
  138.    
  139.        select  e.employee_id ,e.last_name  ,d.department_name
  140.          from employees  e , departments d
  141.          where e.department_id (+) =d.department_id
  142.          union
  143.            select  e.employee_id ,e.last_name  ,d.department_name
  144.          from employees  e , departments d
  145.          where e.department_id  =d.department_id(+);
  146.          
  147.          ---
  148.            select  e.employee_id ,e.last_name  ,d.department_name
  149.          from     departments d   full  outer join  employees  e
  150.          using (department_id );
  151.          
  152.          
  153.             select  e.employee_id ,e.last_name  ,d.department_name
  154.          from    employees  e    full  outer join  departments d
  155.          using (department_id );
  156.          
  157.          ----
  158.          
  159.          SELECT last_name, salary
  160. FROM   employees
  161. WHERE  salary > any
  162.                (SELECT salary
  163.                 FROM   employees
  164.                 WHERE  last_name  like 'T%');
  165.                 ----
  166.      
  167. select  last_name from employees order by 1;
  168.            
  169.         SELECT last_name, job_id, salary
  170. FROM   employees
  171. WHERE  job_id  in   
  172.                 (SELECT job_id
  173.                  FROM   employees
  174.                  WHERE  last_name = 'Taylor')
  175. AND    salary  in
  176.                 (SELECT salary
  177.                  FROM   employees
  178.                  WHERE  last_name = 'Taylor');
  179.                  
  180.                  
  181.                  ---
  182.                  
  183.                    SELECT last_name, job_id, salary
  184. FROM   employees
  185. WHERE  (job_id , salary)  in   
  186.                 (SELECT job_id , salary
  187.                  FROM   employees
  188.                  WHERE  last_name = 'Taylor')
  189. ;               
  190.                
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-12-5 10:34 , Processed in 0.040754 second(s), 24 queries .

快速回复 返回顶部 返回列表