--1.顯示所有員工的姓名,部門號和部門名稱
select last_name,department_id,department_name
from employees e,departments d
where e.department_id=d.department_id(+)
select last_name,e.department_id,department_name
from employees e left outer join departments d
on e.department_id =d.department_id
--2.查詢90號部門員工的job_id和90號部門的location_id
select distinct job_id,location_id
from employees e left outer join department d
on e.department_id=d.department_id
where d.department_id=90
--3.選擇所有有獎金的員工的資訊
select last_name,department_name,d.location_id,city
from employees e join departments d
on e.department_id=d.department_id
join lacation l
on d.location_id=l.location_id
where e.commission_pct is not null;
--4,選擇city在toronto工作的員工的
select last_name,job_id,department_id,department_id
from employees e ,departments d,locations l
where e.department_id=d.department_id and l.city='toronto'
and d.location_id=l.lacation_id;
pl sql多表查詢練習題01
1,多表連線查詢時,若兩個表有同名的列,必須使用表的別名對列名進行引用,否則出錯!2,查詢公司員工的last name,department name,city select last name,department name,city from departments s,employees e,...
多表查詢練習題
部門表 create table dept id int primary key primary key,部門id dname varchar 50 部門名稱 loc varchar 50 部門所在地 新增4個部門 insert into dept id,dname,loc values 10,教學...
PLSQL 練習題目
1.sql練習 查詢emp表各個部門的總工資 select deptno,sum sal from emp group by deptno 2.sql練習 找到emp表中部門總工資最高的那個部門 select from select deptno,sum sal sum sal from emp g...