Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Column with minimum null values

NSK2KSNFeb 11 2016 — edited Feb 12 2016

Hi All,

I have below table

create table nsk_abc(a number, b number, c number);

insert into nsk_abc values (1,null,2);

insert into nsk_abc values (null,3,4);

insert into nsk_abc values (null, 5, 6);

insert into nsk_abc values (2, null, null);

commit;

Expected output :

is Column C because it contains least NULLS out of columns a and b.

using below query, am able to get the minimum column that is having outtput as Null Values, but how to get the values of the column

select sum(decode(a,null,1,0)) a_null_cnt,

sum(decode(b,null,1,0)) b_null_cnt,

sum(decode(c,null,1,0)) c_null_cnt

from nsk_abc

i.e., column C with values 2, 4, 6 and NULL should be returned, am only able to find the column, but how retrive the values in sql

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 11 2016
Added on Feb 11 2016
17 comments
855 views