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
How to generate the Catalog in Cognos? Basically all post describing generating the Catalog from cognos impromptu . Is there any way to generate the Catalog using Cognos Administration or Framework Manager?
Define catalog in cognos and write its various types?
Cleared COG-112 with 100% score today. What next certification should i go for?
What are the types of security?
how can you get the errors in job? when loops are araised we get error?
what r the reports u faced critical and how it can be solved .. any once can u give a best ans for interviw
what do u mean by bridge group? where we r using this one?
What are products of cognos?
Explain informatica architecture?
Can you define cube?
what are the errors faced while bursting the reports and how to solve those errors?
What is drill down and slicing and dicing whats the difference between them?
3. The vice president of sales has requested a graphical display of the same information provided in our last crosstab report (whatever I mentioned in above question) for an up coming presentation. We need to provide a chart report that shows which regions generate the most revenue and sales volume.
which type of project we r going to snowflake schema
What are the types of folder present in cognos?