使用scott/tiger用戶下的emp表和dept表完成下列練習
emp員工表(empno員工號/ename員工姓名/job工作/mgr上級編號/hiredate受雇日期/sal薪金/comm傭金/deptno部門編號)
dept部門表(deptno部門編號/dname部門名稱/loc地點)
工資 = 薪金 + 傭金
===============================================
使用scott/tiger用戶下的emp表和dept表完成下列練習
emp員工表(empno員工號/ename員工姓名/job工作/mgr上級編號/hiredate受雇日期/sal薪金/comm傭金/deptno部門編號)
dept部門表(deptno部門編號/dname部門名稱/loc地點)
工資 = 薪金 + 傭金
select * from dept
where deptno in
(select deptno from emp group by deptno having count(*)>
select * from emp
where sal>(select sal from emp where ename=
select ename
或
select ename
自連接
select a
where a
select ename from emp a
where hiredate>(select hiredate from emp where empno=a
列出受雇日期早於其直接上級的所有員工
select ename from emp a where
hiredate<(select hiredate from emp where empno=a
select dname
on dept
select dname
where a
select dname
where a
select (select dname from dept where deptno=a
from emp a
where job=
select job
group by job having min(sal)>
select ename from emp where deptno=(select deptno from dept where dname=
select ename from emp where sal>(select avg(sal) from emp);
select * from emp where job=(select job from emp where ename=
select * from emp where sal in
(select sal from emp where deptno=
或
select * from emp where sal = any
(select sal from emp where deptno=
select * from emp where sal>all
(select sal from emp where deptno=
select * from emp where sal < all
(select sal from emp where deptno=
select deptno
trunc(avg(sal+nvl(comm
to_char(to_date(
from emp group by deptno;
select ename
select a
from dept a ;
select job
這樣寫有問題
select job
select min(sal) from emp where job=
select ename
SELECT d
SELECT d
+放在沒有匹配行的表一側
select dept
on emp
select dept
on emp
select dept
on emp
From:http://tw.wingwit.com/Article/program/Oracle/201311/16740.html