Query to get max and second max in oracle in one query ?
Answer Posted / sumit wadhwa
for max
select a.sal
from emp a
where 1=(select distinct(count(b.sal))
from emp b
where a.sal<=b.sal);
for second max
select a.sal
from emp a
where 2=(select distinct(count(b.sal))
from emp b
where a.sal<=b.sal)
Is This Answer Correct ? | 33 Yes | 11 No |
Post New Answer View All Answers
ur a sql devoloper...what is the process in ur company for finding the database BUGS .. seperate DB testers are there? or devr.s are manage? if DB TESTERS in there what is the process
How to delete a column in an existing table?
What is ADDM Advisor in Oracle?
How to connect ms access to oracle servers?
How to revoke create session privilege from a user in oracle?
How to use values from other tables in update statements using oracle?
What are the different oracle database objects?
1) What is ONE_SIZE_FITS_ALL approach? 2) Explain the Common & Variable Header of DATA FILE? 3) What are the Drawbacks to using OMF DB? and the Advantages? 4) List out the Advantages of Undo T.spaces over the Undo SEGMENT? 5) Difference between the Temporary tablespace with TEMPFILE and the Tablespace with TEMPORARY Keyword? 6) What are the situation extents are freeing for reuse.
How to define a cusotmer as a supplier in ORACLE R12
How to insert a new row into a table in oracle?
How do I uninstall oracle 11g?
How to calculate date and time differences in oracle?
How to get maxsal , minsal, ename department wise in single query
Explain joins in oracle?
Can a formula column be obtained through a select statement ?