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
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 |
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 |
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 |
Answer / prashanth
user greatedt function.
Ex select greatest(sal,bonus) from emp where emp_id = 1000;
| Is This Answer Correct ? | 2 Yes | 6 No |
What is dynamic SQl and how you will create and execute dynamic sql?
What is the purpose of normalization?
How to improve the performance of a pl/sq stored procedures or functions or triggers and packages ?
12 Answers IBM, TCS, UHD,
what are local and global variables and their differences? : Sql dba
what is the command for user data type?
How do I tune a sql query?
what are different types of collation sensitivity? : Sql dba
how tsql statements can be written and submitted to the database engine? : Transact sql
What are instead of triggers?
What cursor type do you use to retrieve multiple recordsets?
17 Answers Apollo, CTS, IonIdea, Microsoft, Oracle, TCS, Vmoksha, Wipro,
How do you delete duplicates in sql query using rowid?
how to insert the data through views? The view is depending upon more than two tables? how to update materalized views?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)