zoukankan      html  css  js  c++  java
  • 简单的oracle sql语句练习

    简单的oracle sql语句练习

    求每个部门的平均薪水

    select deptno,avg(sal) from emp group by deptno
    

    每个部门同一个职位的最大工资

    select deptno,job,max(sal) from emp group by deptno,job
    

    按照部门编号进行分组,分组之后求每一个部门的平均薪水,要求显示平均薪水大于2000的部门的部门编号和平均薪水

    select deptno,avg(sal) group by deptno having avg(sal)>2000
    

    where和having的区别

    • 1.having配合group by使用
    • 2.where执行在分组前,having执行在分组后

    薪水大于1200的雇员,按照部门编号进行分组,分组之后平均薪水必须大于1700,求分组内的平均工资,平均工资按降序排列

    select deptno,avg(sal) from emp where sal>1200 group by deptno having avg(sal)>1500 order by avg(sal) desc
    

    求最大工资那个人的姓名和薪水

    select ename,sal from emp where sal =(select max(sal) from emp)
    

    最大工资

    select max(sal) from emp
    

    哪些人的工资位于 所有人得平均工资之上

    select ename,sal from emp where sal>(select avg(sal) from emp)
    

    所有人的平均工资

    select avg(sal) from emp
    
  • 相关阅读:
    【2020Python修炼记】网络编程(三)socket编程之粘包
    2020python作业——scoket编程(一)
    月考二
    【2020Python修炼记】网络编程(二)socket编程之socket 的介绍+TCP/UDP
    Gym100889L
    poj3233
    upper_bound
    lower_bound
    Gym-102141E
    P1020 导弹拦截
  • 原文地址:https://www.cnblogs.com/hgnulb/p/9903972.html
Copyright © 2011-2022 走看看