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



The table has 3 columns 4 rows. The output is which column has least null values( A COL SHOULD BE TH..

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

The table has 3 columns 4 rows. The output is which column has least null values( A COL SHOULD BE TH..

Answer / ravi gali

select c from tablename
where c IS NOT NULL;

Is This Answer Correct ?    2 Yes 4 No

Post New Answer

More Oracle General Interview Questions

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

2 Answers   Mind Tree,


what is primary key and foreign key when and where have to use

5 Answers  


What is the difference between truncate & delete command?

0 Answers  


What is the difference between substr & instr functions?

0 Answers  


How to login to the server without an instance?

0 Answers  






What is oracle open database communication (odbc)?

0 Answers  


how table is defined in plsql table? how can i select column from plsql table? can i use select * from plsql table type?

1 Answers  


How to empty your oracle recycle bin?

0 Answers  


What does `(+)` do in a where clause?

1 Answers  


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>

2 Answers   Wipro,


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'));

0 Answers   IBM,


What is the order of defining local variables and sub procedures/functions?

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)