1、显示所有员工的姓名、部门号和部门名称

    1. select last_name,d.department_id,department_name
    2. from employees e,departments d
    3. where e.department_id=d.department_id;

    2、查询90号部门员工的job_id和90号部门的location_id

    1. select job_id,location_id
    2. from employees e,departments d
    3. where e.department_id=d.department_id
    4. and e.department_id=90;


    3、选择所有有奖金的员工的last_name,department_name,location_id,city

    1. select last_name,department_name,lication_id,city
    2. from employees e,departments d,locations l
    3. where e.department_id=d.department_id
    4. and d.location_id=l.location_id
    5. and e.commission_pct is not null;

    4、选择city在Toronto工作的员工的last_name,department_name,department_id

    1. select last_name,department_name,department_id
    2. from employees e,departments d,locations l
    3. where e.department_id=d.department_id
    4. and d.location_id=l.location_id
    5. and city ='Toronto';

    5、查询每个工种,每个部门的部门名、工种名和最低工资

    1. select j.job_id,department_name,min(salary)
    2. from jobs j,departments d,employees e
    3. where e.department_id=d.department_id
    4. and e.job_id=j.job_id
    5. group by department_name,job_id;

    6、查询每个国家下的部门个数大于2的国家编号

    1. SELECT country_id,count(*) 部门个数
    2. FROM departments d,locations l
    3. WHERE d.location_id=l.location_id
    4. GROUP BY country_id
    5. having count(*)>2;

    7、选择指定员工的姓名、员工号,以及他的管理者的姓名和员工号,结果类似于下面的格式
    employees Emp# manager Mgr#

    1. select e.last_name "employees",e.employee_id "Emp#",m.last_name "manager",m.employee_id "Mgr#"
    2. from employees e,employees m
    3. where e.manager_id=m.employee_id