i have a table with 3 columns country,empname,salary and i want the query for get the  name of the employees who is getting top 2 nd highest salary for individual country?
Thanks in advance 

Answers were Sorted based on User's Feedback



i have a table with 3 columns country,empname,salary and i want the query for get the  name of ..

Answer / krish

Query to get 1st max salary from each dept
 
SELECT maxsal, 
       deptno, 
       ename 
FROM   ( 
                SELECT   Max(sal) OVER (partition BY detpno ORDER BY sal)        AS maxsal, 
                         row_number over (partition BY detpno ORDER BY sal DESC) AS id, 
                         ename, 
                         deptno 
                FROM     emp) 
WHERE  id=1;

just place id=2 instead of id=1 for second max salary 
if ur are expecting more than 1 records with max sal 
replace ROW_NUMBER with DENSE_RANK()

http://netezzamigration.blogspot.com/2014/10/analytic-functions-in-netezza.html

Is This Answer Correct ?    5 Yes 0 No

i have a table with 3 columns country,empname,salary and i want the query for get the  name of ..

Answer / madhu

select * from ( select country,empname,salary, dense_rank() over (partition by country order by salary) rank from emp) where rank <= 2;

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More Cognos Interview Questions

i was asked what are the caluclations done by you in your report? plz give reply

0 Answers   IBM,


Define the slice and dice?

0 Answers  


whats the difference between previous version of cognos and cognos 8 BI?

1 Answers   IBM,


What are query items?

0 Answers  


architecture of cognos8

1 Answers   IBM, Sonata,






What is Metrics designer?

0 Answers  


what is symmetric key?where do u use this?

1 Answers  


What is a Cube?

0 Answers  


How to pass parameter value into html design page?

1 Answers  


What is a Pivot?

0 Answers  


set scope level in transformer

2 Answers  


difference between boxtype and visiable

1 Answers   IBM,


Categories