先按照发工资排序,工资相同的按照入职日期排序 select ename,job,sal,hiredate from emp order by sal desc,hiredate desc;
查询10部门和20部门下员工信息 select * from emp where deptno =10 or deptno =20;
一共有几种工作 消除重复行,获取唯一结果 select distinct job from emp ;
查询没有补助的员工信息 select * from emp where comm is null; select * from emp where comm is not null;
--模糊查询姓名中带A的员工信息 select * from emp where ename like '%A%'; --第二个字母是A select * from emp where ename like '_A%';
--内容包含'30%'的信息 select * from emp where ename like '%30\%%' escape '\'
--区间查询 select ename,sal from emp where sal >=2000 and sal <=3000; select ename,sal from emp where sal between 2000 and 3000; --不在区间范围内 select ename,sal from emp where sal not between 2000 and 3000; select ename,sal from emp where sal < 2000 or sal >3000;