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
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 |
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 |
What are the best practices while building a Cognos Framework Manager Package ? As in, what calculations would you not like to be handled in FM and rather get it directly from Database.
17. How can we display tabs in the report Footer (Ex; PAGE 1 2 3 4 5...last)?
how can we improve performance of the reports?
what are the dimensions that you have in your current project?list them?
What is difference between informatica power mart and power center?
write a query to display to 10 max record from the employee table?
Name the types of report?
I would appreciate if any one answer for this, I have faced the question like this, the question was Tell me some complex reports, which u faced?
what is a query subjects item?
what is session parameters? what is use?
How can we give the same color for alternate(1,3,5.... and 2,4,8...) cells in a column?
diff b/w grouping and aggregation