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 2
NULL 3 4
NULL 5 6
7 NULL NULL

O/P

C
=
2
4
6

Answer Posted / rameshganesan

Select (Case
When a = Least Then (select 'A'||CHR(10)||'='||CHR(10)||ListAgg(a,CHR(10)) Within Group(order by a) from Least_Col)
When b =Least Then (select 'B'||CHR(10)||'='||CHR(10)||ListAgg(b,CHR(10)) Within Group(order by b) from Least_Col)
Else (select 'C'||CHR(10)|| '='||CHR(10)||ListAgg(c,CHR(10)) 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 ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

src name sex a,male b,female c,male d,female Required output : male female a,b c,d tried pivot but was not successfull select * from src pivot (max(name) for sex in ('MALE','FEMALE'));

1174


Explain the use of indexes option in exp command.

588


What to do if the startbd.bat failed to start the xe instance?

603


What is the string concatenation operator in oracle?

563


How to export your own schema?

560






Is oracle a language?

515


How to find out what oracle odbc drivers are installed?

562


How to rename an index in oracle?

612


Is oracle a programming language?

557


Oracle

1837


What are temporal data types in oracle?

592


What is format trigger?

1612


What is ASM (Automatic Storage Management) in Oracle?

705


State and explain the different types of data models?

525


Please explain oracle left join with an example?

577