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
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'));
Explain the use of indexes option in exp command.
What to do if the startbd.bat failed to start the xe instance?
What is the string concatenation operator in oracle?
How to export your own schema?
Is oracle a language?
How to find out what oracle odbc drivers are installed?
How to rename an index in oracle?
Is oracle a programming language?
Oracle
What are temporal data types in oracle?
What is format trigger?
What is ASM (Automatic Storage Management) in Oracle?
State and explain the different types of data models?
Please explain oracle left join with an example?