select deptno, count(*) from EMP group by DEPTNO having count(*) >1
--2
select * from emp where sal > (select sal from emp where ename = 'SMITH')
--3
select e0.ENAME, e1.ename from emp e0, emp e1 where e0.MGR = e1.empno
--4
select e0.*, e1.* from emp e0, emp e1 where e0.mgr = e1.empno(+) and e0.hiredate < e1.hiredate
--5
select d.dname, e.* from dept d, emp e where d.deptno = e.deptno(+)
--6
select e.ename, d.dname from emp e join dept d on e.deptno = d.deptno where job = 'CLERK'
--7
select job from emp group by job having min(sal) > 1500
--8
select e.ename from emp e, dept d where d.dname = 'SALES' and e.deptno(+) = d.deptno
--9
select * from emp where sal > (select avg(sal) from emp)
--10
select * from emp where job = (select job from emp where ename = 'SCOTT')
--11
select * from emp where sal in (select sal from emp where deptno = 30)
--12
select * from emp where sal > all (select sal from emp where deptno = 30)
--13
select count(empno) 人数, avg(sal) 平均工资, avg(EXTRACT(year FROM sysdate) - EXTRACT(year FROM emp.hiredate)) 平均雇佣期限 from dual, emp group by deptno
--14
select e.ename, d.dname, e.sal from emp e, dept d where e.deptno = d.deptno(+)
--15
select d.*, t.count from dept d, (select deptno, count(empno) count from emp group by deptno) t where d.deptno = t.deptno(+)
--16
select job, min(sal) from emp group by job
--17
select deptno, min(sal) from emp where job = 'MANAGER' group by deptno
emp表与PLSQL Developer 无关,PLSQL Developer 是个工具,而emp是oracle数据库自带的scott用户下的一个表。可以通过登陆scott用户来使用,scott用户的密码是tiger。如果无法登陆,有可能是由于scott用户被锁定,执行解锁语句就可以了。解锁步骤:
首先,使用管理员登陆 as sysdba
conn system/你的密码 as sysdba
然后,对scott进行解锁
alter user scott account unlock
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)