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

Is big data nosql?

0 Answers  


How can we debug in PL/SQL?

0 Answers  


What is a parameter query?

0 Answers  


What is coalesce sql?

0 Answers  


What is scalar function in sql?

0 Answers  






What is the starting oracle error number? What is meant by forward declaration in functions?

0 Answers  


What is nvl?

0 Answers  


What is difference between sql and excel?

0 Answers  


How do you run a query?

0 Answers  


What is a heap in sql?

0 Answers  


explain access control lists. : Sql dba

0 Answers  


What are the parts of a basic sql query?

0 Answers  


Categories