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 do I trace sql profiler?

0 Answers  


What is normalization sql?

0 Answers  


What is sqlservr exe?

0 Answers  


How much does sql cost?

0 Answers  


Can we join more than 2 tables in sql?

0 Answers  






How do you retrieve the last N records from a table?

10 Answers  


What is sql lookup?

0 Answers  


What are the string functions in sql?

0 Answers  


What is a sql*loader control file?

0 Answers  


What is the order of sql select?

0 Answers  


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  


TABLE A TABLE B EMPNO ENAME EMPNO ENAME 1 A 1 A 2 B 2 B 3 C 3 C 4 D 4 D 5 E 5 E 6 F 7 G HOW TO GET THE UNMATCHED RECORDS IN SQL QUERY?

10 Answers   Satyam,


Categories