mysql语句基本练习
select ename,job from emp where job in ('MANAGER','ANALYET','SALESMAN')
1.查询出工作岗位为MANAGER、ANALYST、SALESMAN的员工姓名、岗位名称
select * from emp where ename like ('_A%')
2.查询emp表中,ename的值第二个字符是A的员工信息
3.select * from emp where ename like '%M%'
4.查询emp表中,员工姓名的值中包含M的员工
5.select * from emp where ename like '%A_B'
6.查询emp表中,ename的值包含A+任意一个其他字符+B的员工信息
select * from emp where comm is not null or deptno=20 order by sal desc
7.查询emp表,显示佣金不为空或者部门号为20的雇员信息,要求按照薪水降序排列
8.select * from emp where (sal+nvl(comm,0))*12>30000 and job not in 'MANAGER' or deptno not in (10,40) order by ename
9.查询emp表中年薪大于30000,工作岗位不是MANAGER且部门编号不是10和40.通过名字排列
select * from emp where lower(job)='clerk'
select * from emp where upper(job)='CLERK'
10.查询出岗位名称为CLERK的员工信息,分别使用upper()和lower()函数
select ename,to_char(hiredate,'yyyy-month-day') from emp
11.查询出员工的姓名和入职日期,年为拼写的年,月为全月名,日为全天名
select * from emp where to_char(hiredate,'yyyy')='1980'
12.查询1980入职的员工姓名
select ename,emp.deptno,dept.dname from emp,dept
where emp.deptno=10 and emp.deptno=dept.deptno
13.查询出10部门中员工的姓名、部门编号、部门名称
select job,avg(sal) from emp group by job order by avg(sal)
14.查询每个职位的平均工资,按照平均工资排序