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
Answer Posted / 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 |
Post New Answer View All Answers
Name the types of report?
Can you define fan trap?
What is the use of report studio?
hi..i'm searching on cognos.i want to know some real time explanation..persons who have real time exp and who r searching in this field..can u send ur mail-id..my mail-id is dhaanuus@gmail.com..hope u will respond as soon as possible..
Why cognos decision stream is used?
What is meant by junk dimension?
What are the advantages of shortcuts?
What is the advantage of using shortcuts?
How Metrics Studio is better than Report Studio?
What are the considerations regarding performance kept in mind while setting up cognos?
Looking for IBM COGNOS Certification C1000-065 , C2020-605 , C2090-621 , C2090-623 Dumps?
What is model?
What is the difference between ‘macro’ and ‘prompt?
How can reports be bursted based on two groups? I want to schedule to burst a report based on product line and years and I need the burst report for every product line and every year. How can this be done? Please help..
what are the names of the reports that you prepared?