• oracle练手(一)


    练手001

    1.列出至少有一个员工的所有部门
    select dname from dept where deptno in (select deptno from emp);
    select dname from dept where deptno in (select deptno from emp group by deptno having count(EMPNO)>=1);
    select dname from dept a where exists (select null from emp b where a.DEPTNO=b.DEPTNO);
    2.列出工资比smith工资多的员工信息 select * from emp where sal > (select sal from emp where ENAME='SMITH'); select * from emp a where exists(select null from emp b where a.sal>b.sal and b.ename='SMITH');
    3.列出所有员工的姓名及其直接上级的姓名 select ENAME,(select ENAME from emp a where a.EMPNO=b.MGR) boss from emp b; select a.ename emp, b.ENAME boss from emp a, emp b where a.MGR=b.EMPNO(+);
    4.列出受雇日期早于其直接上级的所有员工姓名 select a.ename from emp a where a.HIREDATE<(select HIREDATE from emp b where a.MGR=b.EMPNO);
    5.列出部门名称和这些部门的员工信息 select dname,b.* from dept a, emp b where a.deptno=b.deptno;
    6.列出所有‘clerk’员工的姓名及部门名称 select a.ename,b.dname from emp a, dept b where a.job='CLERK' and a.deptno=b.deptno;
    7.列出最低工资大于1500的各种工作名 select distinct job from emp group by job having min(sal)>1500; select distinct job from emp a where sal>1500 and not exists(select null from emp b where a.job=b.job and a.sal>b.sal);

      

  • 相关阅读:
    一个在LINUX里安装MS LIB的工具
    Debian 5网易更新源
    ZT:apache转发实现iis和apache共享80端口
    SuSE 安装 永中Office
    [ZT]用dd备份主引导记录
    opensuse 11.3使用fcitx的办法
    在debian5上安装vmware server 2.0.2的尝试
    VHCS wait to be added问题解决
    debian里的NAT转发设置
    Linux操作系统下安装USB移动硬盘的方法
  • 原文地址:https://www.cnblogs.com/sjxbg/p/11363073.html
Copyright © 2020-2023  润新知