The table has 3 columns 4 rows. The output is which column has least null values( A COL SHOULD BE THE OUTPUT)
Write the query plz.

A B C
----------
1 NULL 7
2 4 NULL
NULL 5 NULL
3 NULL NULL

Answer Posted / rameshganesan

Select (Case
When a = Least Then (select 'O/P A ='||ListAgg(a,' ') Within Group(order by a) from Least_Col)
When b =Least Then (select 'O/P B ='||ListAgg(b,' ') Within Group(order by b) from Least_Col)
Else (select 'O/P C ='||ListAgg(c,' ') Within Group(order by c) from Least_Col) end)ab
From (Select count(a) a,count(b) b,count(c) c,greatest(count(a),count(b),count(c)) Least From Least_Col);

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is oracle an open source?

627


What is connection pool in oracle?

545


What do database buffers contain?

557


What is difference between truncate and delete?

549


is there a tool to trace queries, like profiler for sql server?

583






what is difference between sql plus and sql*plus? (not sql and sql plus).

3337


How to change system global area (sga) in oracle?

561


How do I decide when to use right joins/left joins or inner joins or how to determine which table is on which side?

534


What is merge in oracle?

550


Explain oracle’s system global area (sga).

611


Explain the use of indexes option in imp command.

557


Is there an oracle sql query that aggregates multiple rows into one row?

536


How do I manually create a database in oracle?

527


What is control file used for?

594


What is tns entry?

613