当前位置:首页 > 数据库 > Oracle

Oracle数据库的上机作业

技术分享

            select  department_name,city,count(*)
from departments d, employees e, locations l
where e.department_id=d.department_id 
and l.location_id=d.location_id 
and e.salary>1000groupby department_name,city havingcount(*) >2;

技术分享

            select first_name||||last_name name,salary
from employees
where salary between(selectavg(salary)
from employees  
where department_id=50)and(selectavg(salary) from employees where department_id=80);

技术分享

            select  first_name ||‘‘|| last_name ,salary ,department_id
from employees 
where salary=(selectmax(salary) from employees);

技术分享

技术分享

selectemployee_id,first_name,last_name,salary,commission_pct,salary*(1+NVL(commission_pct,0)) totalincome
from employees 
orderby totalincome;

技术分享

            select  first_name ||‘‘|| last_name  name  ,salary ,department_id
 from  employees 
 where (salary ,department_id)
        in ( 
        selectmax(salary),department_id from  employees groupby department_id);

技术分享

            select employee_id,first_name||||last_name name,salary,department_id, 
(selectavg(salary) from employees emp  where emp.department_id=e.department_id ) avgsal
from employees e
where salary>(selectavg(salary) from employees emp  where emp.department_id=e.department_id )
orderby department_id,employee_id;

技术分享

            SELECT department_id , avgsal from 

      (SELECT ROWNUM no, department_id , avgsal 

         from ( select department_id ,avg(salary) avgsal from employees 
  groupby  department_id  orderbyavg(salary))

       WHERE ROWNUM <=2)where no=2;

技术分享

            select employee_id,first_name||||last_name name,salary,department_id, 
(selectavg(salary) from employees emp  where emp.department_id=e.department_id ) avgsal
from employees e
where salary>(selectavg(salary) from employees emp  where emp.department_id=e.department_id )
orderby department_id,employee_id;

技术分享

技术分享

            select
            level
             ,employee_id ,first_name, last_name ,manager_id

            from
             employees 
start 
            with first_name=Davidand last_name=Austin
connect by prior manager_id=employee_id   orderbyleveldesc;

技术分享

            select department_id,employee_id,first_name||||last_name,salary,salrank
from (select department_id,employee_id,first_name,last_name,salary,
dense_rank() over (partition by department_id orderby salary desc) salrank from employees)
where salrank<=3orderby department_id desc,salrank;

 

原文:http://www.cnblogs.com/LJJ1010/p/4384379.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐