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

Whate is use of MOD function in pl/sql.

3 Answers   Oracle,


what happens when the column is set to auto increment and you reach the maximum value for that table? : Sql dba

0 Answers  


Why is normalization important?

0 Answers  


What are user defined stored procedures ?

3 Answers   BirlaSoft,


does sql support programming? : Sql dba

0 Answers  






What is compute?

0 Answers  


What is a merge query?

1 Answers  


What is a REF CURSOR? Compare strong and week ref cursor types.

6 Answers  


What is a left join?

0 Answers  


what are the maximum number of rows that can be constructed by inserting rows directly in value list? : Transact sql

0 Answers  


Why do we use procedures?

0 Answers  


Write a pl/sql script to display the following series of numbers: 99,96,93……9,6,3?

1 Answers  


Categories