【oracle】限定查询与排序显示

SELECT *

FROM emp

WHERE SAL>1500;

 

SELECT *

FROM EMP

WHERE ENAME='SMITH';

 

SELECT *

FROM EMP

WHERE JOB='CLERK';

 

SELECT *

FROM emp

WHERE JOB<>'CLERK';

 

SELECT *

FROM emp

WHERE JOB!='CLERK';

 

SELECT *

FROM emp

WHERE SAL>=1500 AND SAL<=3000;

 

SELECT *

FROM emp

WHERE JOB='SALESMAN' AND SAL>=1500;

 

SELECT *

FROM emp

WHERE (DEPTNO=10 AND JOB='MANAGER') OR(DEPTNO=20 AND JOB='CLERK');

 

SELECT *

FROM emp

WHERE JOB<>'MANAGER' AND SAL>2000;

 

SELECT *

FROM emp

WHERE SAL BETWEEN 1500 AND 3000;

 

SELECT *

FROM EMP

WHERE HIREDATE BETWEEN '01-1月-1981' AND '31-12月-1981';   --81与1981都一样

 

SELECT *

FROM EMP

WHERE COMM IS NULL;

 

SELECT *

FROM EMP

WHERE COMM IS NULL AND SAL>2000;

 

SELECT *

FROM EMP

WHERE COMM IS NULL OR COMM<100;

 

SELECT DISTINCT JOB

FROM EMP

WHERE COMM IS NOT NULL;

 

SELECT *

FROM EMP

WHERE EMPNO IN(7369,7788,7566);

 

SELECT *

FROM EMP

WHERE EMPNO NOT IN(7369,7788,7566);

 

SELECT *

FROM EMP

WHERE ENAME LIKE 'S%';

 

SELECT *

FROM emp

WHERE ENAME LIKE '_M%';

 

SELECT *

FROM EMP

WHERE ENAME LIKE '______%';

 

SELECT *

FROM EMP

WHERE SAL LIKE '%1%' OR HIREDATE LIKE'%81%';   --带1,带81

 

SELECT *

FROM EMP

ORDER BY SAL DESC,HIREDATE ASC;   --按工资降序,若工资相同,则按日期升序

 

SELECT EMPNO,SAL,ENAME,JOB,HIREDATE

FROM emp

ORDER BY 2 DESC;   --可以使用序号,但不建议使用

你可能感兴趣的:(oracle,oracle)