zoukankan      html  css  js  c++  java
  • Oracle数据库查询语句

    编写以下查询的SQL语句,以scott用户的emp表和dept表作为查询数据:

    1.列出至少有一个员工的所有部门。

    SQL语句:

    select * from SCOTT.DEPT
    where deptno in
    (select distinct deptno from SCOTT.DEPT);

    查询结果:

    2.列出所有员工的姓名及其直接上级的姓名。

    SQL语句:

    select e.ename 员工姓名,m.ename 上级姓名
    from scott.emp e,scott.emp m
    where m.empno=e.mgr;

    查询结果:

    3.列出部门名称和这些部门的员工信息,同时列出那些没有员工的部门。

    SQL语句:

    select d.dname,e.*
    from scott.dept d,scott.emp e
    where d.deptno=e.deptno(+);

    查询结果:

    4.列出最低薪金大于1500 的各种工作。

    SQL语句:

    select job 工作,min(sal) 最低薪金
    from SCOTT.EMP
    group by job
    having min(sal)>1500;

    查询结果:

    5.列出薪金高于公司平均薪金的所有员工。

    SQL语句:

    select *
    from SCOTT.EMP
    where  sal>(select avg(sal) from SCOTT.EMP);

    查询结果:

    6.列出薪金等于部门30 中员工的薪金的所有员工的姓名和薪金。

    SQL语句:

    select ename,sal,deptno
    from SCOTT.EMP
    where sal in (select sal from SCOTT.EMP where deptno=30);

    查询结果:

  • 相关阅读:
    【贴吧】计算器代码注释
    简单理解面向对象思维
    [转载]编程哲理
    Android SDK Manager无法更新的解决方案
    CSS选择器
    javascript arguments参数问题
    html垂直居中
    x64系统WSC注册方法
    SharePoint Server 2013安装
    Asp Url汉字乱码的问题
  • 原文地址:https://www.cnblogs.com/shenxiaolin/p/5723893.html
Copyright © 2011-2022 走看看