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

In a table only one column how to update rows

5 Answers   Microsoft,


How will you delete a particular row from a Table?

7 Answers   Cap Gemini,


How many sectors are in a partition?

0 Answers  


If i can use sys.check_constraints to display my constraints from my database using sql server 2005, how can i display then if i am using sql server 2000????

0 Answers  


Is primary key a clustered index?

0 Answers  






What is the difference between execution of triggers and stored procedures?

0 Answers  


How delete a row in sql?

0 Answers  


What is sqlcommand?

0 Answers  


What is a mutating table and a constraining table?

0 Answers  


please explain database architecture..

1 Answers   Infosys,


How do we accept inputs from user during runtime?

0 Answers  


How to add, remove, modify users using sql?

0 Answers  


Categories