Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to get the second max val for every group in a table

Answers were Sorted based on User's Feedback



how to get the second max val for every group in a table..

Answer / venkat

select * from (
select e.deptno,d.dname,e.sal,dense_rank() over (
partition by e.deptno
order by e.sal desc ) "RANK",
e.ename
from emp_test e,dept_test d
where e.deptno=d.deptno)
where rank=2

Is This Answer Correct ?    9 Yes 5 No

how to get the second max val for every group in a table..

Answer / abc

select max(sal) from emp_test where sal not IN(select
max(sal) from
emp_test group by deptno)group by deptno;

Is This Answer Correct ?    3 Yes 2 No

how to get the second max val for every group in a table..

Answer / suman rana

--venkat u r almost correct, since u have used "" (double
quotes) so column name will be come case sensitive.

select * from (
select e.deptno,d.dname,e.sal,dense_rank() over (
partition by e.deptno
order by e.sal desc ) RANK, e.ename
from emp_test e,dept_test d where e.deptno=d.deptno)
where rank=2

Is This Answer Correct ?    0 Yes 0 No

how to get the second max val for every group in a table..

Answer / suman rana

select * from emp e where 2 = ( select count(distinct sal)
from emp e1 where e1.deptno = e.deptno and E.SAL <= E1.SAL)

Is This Answer Correct ?    0 Yes 0 No

how to get the second max val for every group in a table..

Answer / ram posam

select * from (select deptno,sal,rank() over(partition by
deptno order by sal desc) k
from emp
group by deptno,sal)
where k=&n;

Is This Answer Correct ?    0 Yes 0 No

how to get the second max val for every group in a table..

Answer / indu

select max(sal) from salary where sal NOT IN (select max(sal) from salary)

Is This Answer Correct ?    9 Yes 13 No

Post New Answer

More Oracle General Interview Questions

Hello All, Could any one provide me FAQs/interview questions on oracle PL/SQL

1 Answers  


What are the uses of Database Trigger ?

0 Answers  


Provide an example of a shell script which logs into SQLPLUS as SYS, determines the current date, changes the date format to include minutes & seconds, issues a drop table command, displays the date again, and finally exits.

0 Answers  


What is analyze command used for?

0 Answers  


How to assign data of the deleted row to variables?

0 Answers  


Can group functions be used in the order by clause in oracle?

0 Answers  


Give the advantages and disadvantages of clusters.

0 Answers  


what is the syntax of ALTER command?

8 Answers  


Hi Can any one tell me what are the API's used in requisition import.

0 Answers  


Is it possible to center an object horizontally in a repeating frame that has a variable horizontal size ?

0 Answers   Oracle, TCS,


what happened to the global index when I truncate the data in one of the partition?

0 Answers  


ABOUT IDENTITY?

0 Answers   HCL,


Categories
  • Oracle General Interview Questions Oracle General (1809)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)