日期:2014-05-17  浏览次数:20770 次

急!!!!要显示所有包括空值怎么办
以emp 为例
奖金(comm)小于500或为空的数据
不能使用or,uion,union all,case when


------解决方案--------------------
SQL code
 
SQL> select * from emp where nvl(comm,0)<500;
 
EMPNO ENAME      JOB         MGR HIREDATE          SAL      COMM DEPTNO FLAG
----- ---------- --------- ----- ----------- --------- --------- ------ ----
 7369 SMIT H1    CLERK      7912 1980-12-17     800.00               20 
 7499 ALLE N     SALESMAN   7698 1981-2-20     1600.00    300.00     30 
 7566 JONE S     MANAGER    7839 1981-4-2      2975.00               20 
 7698 BLAK E     MANAGER    7839 1981-5-1      2850.00               30 
 7782 CLAR K     MANAGER    7839 1981-6-9      2450.00               10 
 7788 SCOT T     ANALYST    7566 1987-4-19     3000.00               20 
 7839 KING       PRESIDENT       1981-11-17    5000.00               10 
 7844 TURN ER    SALESMAN   7698 1981-9-8      1500.00      0.00     30 
 7876 ADAM S     CLERK      7788 1987-5-23     1100.00               20 
 7900 JAME S     CLERK      7698 1981-12-3      950.00               30 
 7902 FORD       ANALYST    7566 1981-12-3     3000.00               20 
 7934 MILL ER    CLERK      7782 1982-1-23     1300.00               10 
 
12 rows selected
 
SQL>