2019-07-03

SELECT *

FROM emp

WHERE deptno=10

SELECT *

FROM emp

where ename='KING'

SELECT *

FROM emp

WHERE HIREDATE='1980-12-17'

SELECT *

FROM emp

WHERE HIREDATE='19801217'

SELECT *

FROM emp

WHERE HIREDATE<>'1980-12-17'

SELECT *

from emp

WHERE sal BETWEEN 1250 AND 2450

SELECT *

FROM EMP

WHERE HIREDATE BETWEEN '1980-12-17'AND'1981-03-30'

--查询员工姓名是

IN 语句 值在列表范围内的

SELECT *

from emp

where ename in ('SMITH','BLAKE','CLARK')

SELECT *

from emp

where EMPNO in ('7902','7566','7788')

SELECT ename hiredate

FROM EMP

WHERE HIREDATE  BETWEEN'1982-1-1'AND'1985-12-30';

SELECT *

from emp

where ename like 's%'

SELECT *

from emp

where ename like '%n'

SELECT *

from emp

where ename like 'w%'

SELECT *

from emp

where ename like '%t_'

SELECT *

FROM emp

where mgr is null

SELECT *

FROM emp

where sal

SELECT*

FROM emp

WHERE sal>1000 and JOB='CLERK' AND HIREDATE>'19800101'

SELECT *

FROM EMP

WHERE SAL>1000 OR JOB='elerk'

SELECT *

FROM EMP

WHERE DEPTNO NOT IN(10,20)

SELECT *

FROM EMP

WHERE sal NOT BETWEEN 2000 AND 5000

SELECT *

from emp

where ename not like '%s%'

SELECT *

from emp

where mgr is not null

SELECT *

from emp

WHERE (job='SALESMAN'OR JOB='PRESIDENT')and sal>1500

SELECT ENAME,JOB,SAL

from emp

where (sal>2000 and job='MANAGER') OR JOB='SALESMAN'

SELECT *

from emp

where sal>2000 and (job='MANAGER' OR JOB='SALESMAN')

SELECT ENAME,JOB,SAL

from emp

WHERE JOB='SALESMAN'

SELECT ENAME,JOB,DEPTNO

from emp

WHERE (DEPTNO=10 OR DEPTNO=20) AND ( SAL BETWEEN 3000 AND 5000);

-- 查询职位为SALESMAN或MANAGER,部门编号为10或者20,姓名包含A的员工姓名、职位、部门编号。

SELECT ENAME,JOB,DEPTNO

from emp

WHERE (JOB='SALESMAN' OR JOB='MANAGER')AND (DEPTNO=10 OR DEPTNO=20)AND(ENAME LIKE '%A%')

-- 1.查询部门在20或30的员工姓名,部门编号,并按照工资升序排序。

SELECT ENAME,DEPTNO

FROM EMP

WHERE  DEPTNO=20 OR DEPTNO=30

ORDER BY SAL ASC

-- 2.查询工资在2000-3000之间,部门不在10号的员工姓名,部门编号,工资,并按照部门升序,工资降序排序。

SELECT ENAME,DEPTNO,SAL

FROM EMP

WHERE SAL BETWEEN 2000 AND 3000

AND DEPTNO <>10

ORDER BY SAL DESC, DEPTNO ASC

-- 3.查询入职日期在81年至83年之间,职位以SALES或者MAN开头的员工姓名,入职日期,职位,并按照入职日期降序排序。

SELECT ENAME,JOB,HIREDATE

FROM EMP

WHERE HIREDATE BETWEEN '1981-01-01' AND '1983-12-31'

AND( JOB LIKE 'SALES%'or JOB LIKE'MAN%')

ORDER BY  HIREDATE DESC

-- ?1.查询职位为SALESMAN的员工编号、职位、入职日期。

SELECT empno,job,hiredate

from emp

where JOB='SALESMAN'

-- ?2.查询1985年12月31日之前入职的员工姓名及入职日期。

SELECT ENAME,HIREDATE

FROM EMP

where HIREDATE BETWEEN '1666-01-01'AND '1985-12-31'

-- ?3.查询部门编号不在10部门的员工姓名、部门编号。

SELECT ENAME,DEPTNO

FROM EMP

WHERE DEPTNO <>10

-- 1.查询入职时间在1982-7-9之后,并且不从事SALESMAN工作的员工姓名、入职时间、职位。

SELECT ENAME,HIREDATE,JOB

FROM EMP

WHERE HIREDATE>'1982-07-09' AND JOB <> 'SALESMAN'

-- 2.查询员工姓名的第三个字母是a的员工姓名

SELECT ENAME

FROM EMP

WHERE ENAME LIKE '--A'

-- 3.查询除了10、20号部门以外的员工姓名、部门编号。

SELECT ENAME,DEPTNO

FROM EMP

WHERE DEPTNO NOT IN ( 10, 20)

-- 4.查询部门号为30号员工的信息,先按工资降序排序,再按姓名升序排序。

SELECT *

FROM EMP

WHERE DEPTNO=30

ORDER BY SAL DESC, ENAME ASC

-- 5.查询没有上级的员工(经理号为空)的员工姓名。

SELECT ENAME

FROM EMP

WHERE mgr is null

-- 6.查询工资大于等于4500并且部门为10或者20的员工的姓名\工资、部门编号。

SELECT ENAME,DEPTNO,SAL

FROM EMP

WHERE SAL >=4500 AND (DEPTNO=10 OR DEPTNO=20)

你可能感兴趣的:(2019-07-03)