oracle语句例句

-------分页2---------
SELECT * FROM(SELECT * FROM(SELECT ROWNUM 序号,emp.* FROM emp)e WHERE 序号<9)WHERE 序号>4

------||合并列--------
SELECT ENAME ||'的岗位是'||JOB 姓名工作 FROM EMP

-------重复行--------
SELECT DISTINCT JOB FROM EMP

-------过滤--------
SELECT * FROM EMP WHERE DEPTNO=10 ORDER BY SAL DESC


SELECT * FROM EMP WHERE SAL BETWEEN 2000 AND 5000

SELECT * FROM EMP WHERE DEPTNO IN(10,20)

SELECT * FROM EMP WHERE ENAME LIKE '%A%'

SELECT * FROM EMP WHERE COMM IS NOT NULL


SELECT * FROM EMP WHERE ENAME='SMITH'

-------子连接--------
SELECT * FROM EMP WHERE EMPNO=(SELECT MGR FROM EMP WHERE ENAME='SMITH')

-------自连接--------
SELECT e2.* FROM EMP e1,EMP e2 WHERE e1.MGR=e2.EMPNO AND e1.ENAME='SMITH'


SELECT sal FROM EMP emp WHERE deptno=(SELECT deptno FROM dept WHERE dname='ACCOUNTING')


SELECT * FROM EMP WHERE SAL<ANY(SELECT sal FROM emp WHERE deptno=(SELECT deptno FROM dept WHERE dname='ACCOUNTING'))

 

阅读更多
换一批

没有更多推荐了,返回首页