SQL作业

EX1

9  Find any Clerk who is not in department 10.

 

SELECT * FROM EMP2014170165 E

WHERE JOB = 'CLERK' AND DEPTNO <> 10

ORDER BY EMPNO

 

13 Find all the employees whose last names end with S

 

SELECT * FROM EMP2014170165 E

WHERE TRIM(ENAME) LIKE '%S'

ORDER BY EMPNO

 

15 List only those employees who receive commission.

 

SELECT * FROM EMP2014170165 E

WHERE COMM IS NOT NULL

ORDER BY EMPNO

 

21 Find all the salesmen in department 30 who have a salary greater than  or equal to £18000.

 

SELECT * FROM EMP2014170165 E

WHERE JOB = 'SALESMAN' AND DEPTNO = 30 AND SAL >= 18000

ORDER BY EMPNO

 

Ex2

5 For each employee whose salary exceeds his manager's salary, list the  employee's name and salary and the manager's name and salary.

 

SELECT E1.ENAME,E1.SAL,E2.ENAME,E2.SAL 

FROM EMP2014170165 E1,EMP2014170165 E2

WHERE E1.MGR = E2.EMPNO AND E1.SAL>E2.SAL

 

6 List the employees who have BLAKE as their manager.

 

SELECT E1.*

FROM EMP2014170165 E1,EMP2014170165 E2

WHERE E1.MGR = E2.EMPNO AND E2.ENAME = 'BLAKE'

ORDER BY E1.EMPNO

posted @ 2016-03-17 11:50  qlky  阅读(211)  评论(0编辑  收藏  举报