SQL> create table nvl (a int, b int);
表已創建。
SQL> insert into nvl values (1,1);
已創建 1 行。
SQL> insert into nvl values (2,null);
已創建 1 行。
SQL> insert into nvl values (3,3);
已創建 1 行。
SQL> commit;
提交完成。
SQL> select count(nvl(b,0))
2 from nvl where b is null;
COUNT(NVL(B,0))
---------------
1
SQL> select * from nvl where b is null;
A B
---------- ----------
2
SQL> select count(*) from nvl where b is null;
COUNT(*)
----------
1
SQL> select count(b) from nvl wehre b is null;
select count(b) from nvl wehre b is null
*
第 1 行出現錯誤:
ORA-00933: SQL 命令未正確結束
SQL> select count(b) from nvl wehre b = null;
select count(b) from nvl wehre b = null
*
第 1 行出現錯誤:
ORA-00933: SQL 命令未正確結束
SQL> select count(distinct b) from nvl wehre b is null;
select count(distinct b) from nvl wehre b is null
*
第 1 行出現錯誤:
ORA-00933: SQL 命令未正確結束