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 |
How you create IQD In ReportNet FrameWork?
Can you define metrics designer?
my table having data like this year month revenue 2011 jan 100 2011 feb 200 2011 mar 150 like this i want My report 2011 jan 100 2011 feb 100+200=300 2011 mar 300+150=450 like this for this where we specify the condition how will specify? pls ans me pls...
Guys... which difficult you faced in your projects that should be difficult to you not to others... any one can explain but should be clear steps... and with examples... how you handle that......?
diff b/w dimension and regular dimension
What is Normalization?
explain how to create powerplay reports?
1. We have been asked to add summary information to sales reprasentatives performance report. The report needs to be grouped by country and city to compare performance between areas Also we need to include revenue totals for each city and each country.
what is the diff b/w excel 2000 and excel 2002 sheets if any body know this answer plz tell me
What are the different types of important services used in cognos?
what are versions of cognos from starting release to latest in the market?
I have a value prompt in my prompt page.Now if I set the filter to required then I have to select a value from the list and I will get the respective data in the report page.But If I select nothing then I will get the complete data in the report page. I want that if I select nothing from the prompt list then nothing is displayed in my report page. How should I do this?