How can u find column name from a table which have max value
in a row.( not max value)

Answers were Sorted based on User's Feedback



How can u find column name from a table which have max value in a row.( not max value)..

Answer / ajit

SELECT COUNT(Sal), COUNT(Comm)
FROM Emp;

Is This Answer Correct ?    0 Yes 0 No

How can u find column name from a table which have max value in a row.( not max value)..

Answer / mahalakshmi s

select case when col1>col2 then 'col1' else 'col2' end, greatest(col1,col2) end from table_name;

Is This Answer Correct ?    0 Yes 0 No

How can u find column name from a table which have max value in a row.( not max value)..

Answer / gaurav

select decode( (select sal from emp where empno = 7521) , (select greatest( sal, comm ) from emp where empno = 7521 ), 'sal', 'comm' ) from dual

You can use multiple decode if more number of columns are there.

Is This Answer Correct ?    0 Yes 1 No

How can u find column name from a table which have max value in a row.( not max value)..

Answer / ganesh

create table aa_test(
a number,
b number,
c number)
;

select greatest(a,b,c) from aa_test where a=99 ;

Is This Answer Correct ?    0 Yes 1 No

How can u find column name from a table which have max value in a row.( not max value)..

Answer / prashanth

user greatedt function.

Ex select greatest(sal,bonus) from emp where emp_id = 1000;

Is This Answer Correct ?    2 Yes 6 No

Post New Answer

More SQL PLSQL Interview Questions

How to select the Nth maximum salary from Table Emp in Oracle SQL Plus ?

0 Answers   MCN Solutions,


What are the events on which a database trigger can be based?

0 Answers  


what is a record in a database ? : Sql dba

0 Answers  


What is the use of time stamp in select statement?

1 Answers   TCS,


Which command is used to delete a package?

0 Answers  






Delete duplicate records in the emp table.

6 Answers   Oracle,


Explain polymorphism in pl/sql.

0 Answers  


Hi am new to PLSQL & facing problems in writing code like in SP, Functions, so any one having some SP coding with in depth explanation please share with me my Email ID suvarnaatsuvarna@rediffmail.com Or taking tanning on this please do contact me

0 Answers  


what is the command for user data type?

2 Answers  


How will you select unique values from a list of records?

7 Answers   Cap Gemini,


Hi all, i have a table as follows empid empname mgrid deptid 1 a 3 4 2 b 1 5 3 c 2 3 4 d 3 6 5 e 4 7 i want the output as empname mgrname a c b a c b d c e d

4 Answers  


Name Salary Abc 50000 Abc 50000 xyz 20000 find the max salary using aggregate function?

2 Answers   CTS,


Categories