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 do you mean by Drill down and Drill Up?
What is the difference between macros and prompt?
Hi All, Is there any way to check whether a value is selected in a Multi-select tree prompt? I have a tree prompt and want to get to know whetehr which values user has selected,i want to so that values on the top of the report. I Have used that paramDisplayValue('paramername'),But it will display only last selected value. For Example i have tree prompt with one level Region- >country->states If user select region Asia it will dislay the all the Countries in that region and then if user select India it will display the states related to india only Suppose Hierachy look like this: Asia->India->Andhra Pradesh. I want to show this hierachy on the top of the report How it is possible? Can you please help me?
-----------What is member Description?
how to explain tne project at the time of interview? where to start and how to end? plz explain in detail thax in advance
In one of my report i have one data item sales_amount. If this report is run by one user from india so the sales_amount should be display in indian repees(Rs.) format, if USA user then in dollers($), if UK user then In Pounds.Hou can i achive this? Please answer me.
4 Answers Accenture, HCL, IBM,
Where do i get Free COGNOS 8 Certification Dumps Downloaded for these codes COG-105, COG-112, COG-122, COG-125, COG-132, COG-135, COG- 142, COG-145, COG-180, COG-200, COG-205, COG-300, COG-310, COG-400, COG-480
6. Which of them will increase the performance?
what are the filters in framework manager and report studio?
what is stitch query in reportnet?
What is the diff between the following Report output-- HTML O/P, PDF O/P, EXCEL 2000 and EXCEL 2003 of report outputs? Listout main differences?
how to access the database directly from cognos reportnet