1、显示所有员工的姓名、部门号和部门名称
select last_name,d.department_id,department_namefrom employees e,departments dwhere e.department_id=d.department_id;
2、查询90号部门员工的job_id和90号部门的location_id
select job_id,location_idfrom employees e,departments dwhere e.department_id=d.department_idand e.department_id=90;
3、选择所有有奖金的员工的last_name,department_name,location_id,city
select last_name,department_name,lication_id,cityfrom employees e,departments d,locations lwhere e.department_id=d.department_idand d.location_id=l.location_idand e.commission_pct is not null;
4、选择city在Toronto工作的员工的last_name,department_name,department_id
select last_name,department_name,department_idfrom employees e,departments d,locations lwhere e.department_id=d.department_idand d.location_id=l.location_idand city ='Toronto';
5、查询每个工种,每个部门的部门名、工种名和最低工资
select j.job_id,department_name,min(salary)from jobs j,departments d,employees ewhere e.department_id=d.department_idand e.job_id=j.job_idgroup by department_name,job_id;
6、查询每个国家下的部门个数大于2的国家编号
SELECT country_id,count(*) 部门个数FROM departments d,locations lWHERE d.location_id=l.location_idGROUP BY country_idhaving count(*)>2;
7、选择指定员工的姓名、员工号,以及他的管理者的姓名和员工号,结果类似于下面的格式
employees Emp# manager Mgr#
select e.last_name "employees",e.employee_id "Emp#",m.last_name "manager",m.employee_id "Mgr#"from employees e,employees mwhere e.manager_id=m.employee_id
