Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


i have table T!.

A B C D
NULL 1 2 3
4 NULL 5 6
7 8 NULL 9
10 11 12 NULL.


I WANT COUNT OF NULL VALUES IN TABLE. WRITE A QUERY.

Answers were Sorted based on User's Feedback



i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / naren

select count(*) from t1 where a is null or b is null or c is
null or d is null

Is This Answer Correct ?    26 Yes 3 No

i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / abinash_mishra

SELECT a_null + b_null + c_null + d_null
FROM (SELECT COUNT (DECODE (a, NULL, 1, NULL)) a_null,
COUNT (DECODE (b, NULL, 1, NULL)) b_null,
COUNT (DECODE (c, NULL, 1, NULL)) c_null,
COUNT (DECODE (d, NULL, 1, NULL)) d_null
FROM t_null);

Is This Answer Correct ?    6 Yes 1 No

i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / naren

select
count(decode(a,null,1)),count(decode(b,null,1)),count(decode(c,null,1)),count(decode(d,null,1))
from t1

Is This Answer Correct ?    6 Yes 4 No

i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / ankesh

select sum(nvl2(col1,0,1)+sum(nvl2(col2,0,1)+<...as many
columns we have > from <table name>

Is This Answer Correct ?    2 Yes 0 No

i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / abinash_mishra

SELECT COUNT (DECODE ( a, NULL, 'a',DECODE (b,NULL, 'b',DECODE (c, NULL, 'c', DECODE (d, NULL, 'd', NULL))))) null_count
FROM t_null;

Is This Answer Correct ?    2 Yes 1 No

i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / mathan r

create table clustering
(
id1 varchar(10),
id2 varchar(10),
id3 varchar(10)

)

insert into clustering
select '1','2',null
union
select '1',null,'3'
union all
select null,'2','3'

select sum(nullable) from
(select count(case when id1 = null then '1' else '2' end) 'nullable' from clustering where id1 is null
union all
select count(case when id2 = null then '1' else '2' end)'nullable' from clustering where id2 is null
union all
select count(case when id3 = null then '1' else '2' end)'nullable' from clustering where id3 is null ) tmp

Is This Answer Correct ?    1 Yes 0 No

i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / ramesh

select a1+b1+c1+d1 from
(select count(case when a='null' then 1 end) a1,
count(case when b='null' then 1 end) b1,
count( case when c='null' then 1 end) c1,
count(case when d='null' then 1 end) d1 from t1)

Is This Answer Correct ?    1 Yes 0 No

i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / gaurav

select (count(decode(A,null,1)) + count(decode (B,null,1)) + count(decode(C,null,1) + count(decode(D,null,1))) null_count
from T

Is This Answer Correct ?    1 Yes 0 No

i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / ash

select sum(case when A is null then 1 when B is null then 1
when C is null then 1 when D is null then 1 else 0 end)as
count_null from table T

Is This Answer Correct ?    2 Yes 1 No

i have table T!. A B C D NULL 1 2 3 4 NULL 5 6 7 8 NULL ..

Answer / mani

SELECT A+B+C+D FROM
( select
count(decode(A,null,1)) A,
COUNT(DECODE (B,null,1))B,
COUNT(DECODE (C,null,1))C,
COUNT(DECODE(D,null,1)) D
from PRACTICE2);

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What is the difference between having clause and where clause?

0 Answers  


have table with two columns with datatypes as number and varchar and the values in A column like 1,2,3 AND B column values like a,b,c. now need to display data in a single column as 1,a,2,b,3,c.

8 Answers   IBM, Zensar,


Can we connect to postgresql using sql developer?

0 Answers  


1.when will you use week refcursor and when will you use strong ref cursor ? 2.what is the use of sql trace..how do you use it ? 3.can you please send all the sql plus commands...like set line 6000....

1 Answers   Satyam,


What is partition by in sql?

0 Answers  


Interchange the value of a column Gender in a table where values are Male and Female. So, where the value is Male, it should changed to Female and Female to Male.

4 Answers   Cap Gemini, IBM,


What is sql used for?

0 Answers  


Is it mandatory for the primary key to be given a value when a new record is inserted?

0 Answers  


Is there a way to automate sql execution from the command-line, batch job or shell script?

0 Answers  


What is the cause of mutating table error and how can we solve it?

0 Answers  


What is sql injection owasp?

0 Answers  


What is dml statement?

0 Answers  


Categories