zoukankan      html  css  js  c++  java
  • myslq单表查询

    1.查询出部门编号为30的所有员工
    select * from stu where sid=30;
    
    2.所有销售员的姓名、编号和部门编号。
    select ename,empno,deptno from emp where job='销售员';
    
    3.找出奖金高于工资的员工。
    select * from emp where COMM >sal;
    
    4.找出奖金高于工资60%的员工。
    select * from emp where COMM >sal*0.6;
    
    5.找出部门编号为10中所有经理,和部门编号为20中所有销售员的详细资料。
    select * from emp where (deptno=10 and job='经理') or (deptno=20 and job='销售员');
    
    6.找出部门编号为10中所有经理,部门编号为20中所有销售员,还有即不是经理又不是销售员但其工资大或等于20000的所有员工详细资料。
    select * from emp where (deptno=10 and job='经理') or 
    (deptno=20 and job='销售员') or(job!='销售员'and job!='经理'and sal>20000);
    
    select * from emp where (deptno=10 and job='经理') or 
    (deptno=20 and job='销售员') or
    (job not in ('销售员','经理')and sal>20000);
    
    7.无奖金或奖金低于1000的员工。
    select * from emp where COMM is null or COMM<1000;
    
    8.查询名字由三个字组成的员工。
    select * from emp where ename like '______'; or select * from emp where length(ename)=6;
    
    9.查询2000年入职的员工。
    select * from emp where hiredate like '2000%';
    
    10.查询所有员工详细信息,用编号升序排序
    select * from emp order by  empno asc;
    
    11.查询所有员工详细信息,用工资降序排序,如果工资相同使用入职日期升序排序
    select * from emp order by sal desc ,hiredate asc ;
    
    12.查询每个部门的平均工资
    select deptno,avg(sal) from emp group by deptno;
    
    13.查询每个部门的雇员数量。
    select deptno,count(*) from emp group by deptno;
    
    14.查询每种工作的最高工资、最低工资、人数
    select job,max(sal),min(sal),count(*) from emp group by deptno;
    
    15.查询工资总和大于9000的部门编号以及工资和
    select deptno,sum(sal) from emp group by deptno having sum(sal)>90000;
  • 相关阅读:
    CSS 兼容性调试技巧
    CSS 常用的兼容性调试技巧
    全局CSS设置
    CSS 盒子模型
    CSS表格属性
    HTML引入CSS的方法
    CSS 定位
    CSS display overflow 属性 cursor光标类型
    CSS 继承和优先级
    沟通表达
  • 原文地址:https://www.cnblogs.com/noendtolearning/p/7772843.html
Copyright © 2011-2022 走看看