SQL> select 1 + null as c2,2 as c3 from dual; C2 C3 ---------- ---------- 2 Executed in 0.016 seconds
在oracle中,字符串与null连接不为空
SQL> select '有值' || null as "不为空" from dual; 不为空 ------ 有值 Executed in 0.016 seconds
SQL> select * from emp; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- ---------- ---------- ----------- ---------- ---------- ---------- 7369 SMITH CLERK 7902 1980-12-17 800 20 7499 ALLEN SALESMAN 7698 1981-2-20 1600 300 30 7521 WARD SALESMAN 7698 1981-2-22 1250 500 30 7566 JONES MANAGER 7839 1981-4-2 2975 20 7654 MARTIN SALESMAN 7698 1981-9-28 1250 1400 30 7698 BLAKE MANAGER 7839 1981-5-1 2850 30 7782 CLARK MANAGER 7839 1981-6-9 2450 10 7788 SCOTT ANALYST 7566 1982-12-9 3000 20 7839 KING PRESIDENT 1981-11-17 5000 10 7844 TURNER SALESMAN 7698 1981-9-8 1500 0 30 7876 ADAMS CLERK 7788 1983-1-12 1100 20 7900 JAMES CLERK 7698 1981-12-3 950 30 7902 FORD ANALYST 7566 1981-12-3 3000 20 7934 MILLER CLERK 7782 1982-1-23 1300 10 14 rows selected Executed in 0.032 seconds SQL> SQL> SELECT ename || ' joined on ' || hiredate || 2 ', the total compensation paid is ' || 3 to_char(round(round(SYSDATE - hiredate) / 365) * sal + comm) "COMPENSATION UNTIL DATE" 4 FROM emp; COMPENSATION UNTIL DATE -------------------------------------------------------------------------------- SMITH joined on 17-12月-80, the total compensation paid is ALLEN joined on 20-2月 -81, the total compensation paid is 53100 WARD joined on 22-2月 -81, the total compensation paid is 41750 JONES joined on 02-4月 -81, the total compensation paid is MARTIN joined on 28-9月 -81, the total compensation paid is 42650 BLAKE joined on 01-5月 -81, the total compensation paid is CLARK joined on 09-6月 -81, the total compensation paid is SCOTT joined on 09-12月-82, the total compensation paid is KING joined on 17-11月-81, the total compensation paid is TURNER joined on 08-9月 -81, the total compensation paid is 49500 ADAMS joined on 12-1月 -83, the total compensation paid is JAMES joined on 03-12月-81, the total compensation paid is FORD joined on 03-12月-81, the total compensation paid is MILLER joined on 23-1月 -82, the total compensation paid is 14 rows selected Executed in 0.078 seconds