0

I want to display the number of null values present in each column in a table. something like this.. I have a table called customer and fields in the customer are cust_id,cust_name, cust_add,cust_gender,cust_phone etc

I want output like this

Column name        Number of null values

cust_id                      0
cust_name                    2
cust_add                     5
cust_gender                  3
cust_phone                   5

. . .

and I am using oracle.

4

2 回答 2

2

It's very simple -

SELECT column_name, num_nulls
  FROM all_tab_columns
 WHERE table_name = 'CUSTOMER'; -- Or whatever is your table name.

Read more on Oracle Docs.

于 2013-09-02T07:33:49.510 回答
1

Please try to display data as columns:

select 
    sum(case when cust_id is null then 1 else 0 end) cust_id,
    sum(case when cust_name is null then 1 else 0 end) cust_name, 
    sum(case when cust_add is null then 1 else 0 end) cust_add,
    ..... 
FROM
    customer 
于 2013-09-02T07:34:17.403 回答