简体   繁体   English

NUMBER数据类型字段的Oracle SQL Check空虚

[英]Oracle SQL Check Emptiness of a NUMBER data type field

I have NUMBER(10) column " list_id " and wanted to check if the field is either empty or null. 我有NUMBER(10)列“ list_id ”,并想检查该字段是空还是空。

So I run the following sql statement : 所以我运行以下sql语句:

select list_id from item_list where list_id is null 

This gave me about 200 rows where the field is totally empty (no data) 这给了我大约200行,其中该字段完全为空(无数据)

And then I run the following sql statement: 然后我运行以下sql语句:

select count (list_id) from item_list where list_id is null

To my surprise this returned count(list_id) = 0 令我惊讶的是,此返回的count(list_id)= 0

Is there something I am missing ? 我有什么想念的吗? What I am trying to achieve is find those rows where the list_id is empty or null or contains no data. 我要实现的目标是找到list_id为空或null或不包含任何数据的那些行。

Use count(*) : 使用count(*)

select count(*)
from item_list
where list_id is null;

By definition, count(<expression>) counts the number of rows with non- NULL values for the expression. 根据定义, count(<expression>)count(<expression>)具有非NULL值的行数进行计数。 This is well documented , as well as being how COUNT() works in all databases: 这是有据可查的 ,还有COUNT()在所有数据库中的工作方式:

If you specify expr, then COUNT returns the number of rows where expr is not null. 如果指定expr,则COUNT返回expr不为null的行数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM