• 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;
  • 相关阅读:
    ti8168 eth0 启动
    MVC 5 Ajax + bootstrap+ handle bar 例: 实现service 状态
    MinGW 介绍
    VC POST表单——登录验证新浪邮箱
    关于ActionContext.getContext()的使用方法心得
    java对象数组
    播放音乐案例
    service
    监听短信(监听系统广播)
    普通广播接收者和有序广播接收者
  • 原文地址:https://www.cnblogs.com/noendtolearning/p/7772843.html
Copyright © 2020-2023  润新知