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
Answers were Sorted based on User's Feedback
Answer / 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 |
9)When information has to be stored w.r.t employees and their respective departments, which of the following is the Correct formulation of entries? A)Employee and department would together be represented as an entity. B)This is too less information to decide on entities. C)An employee would be one entity and a department would be another. D)Such a scenario cannot be modelled in RDBMS
what is primary key and foreign key when and where have to use
What is the difference between truncate & delete command?
What is the difference between substr & instr functions?
How to login to the server without an instance?
What is oracle open database communication (odbc)?
how table is defined in plsql table? how can i select column from plsql table? can i use select * from plsql table type?
How to empty your oracle recycle bin?
What does `(+)` do in a where clause?
18. Display the clientno and total value for all orders placed by that client. Output the result in the following format: Client <clientno> has placed orders to the value of <total value>
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'));
What is the order of defining local variables and sub procedures/functions?