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
Explain what is the difference between native sql and cognos sql?
plsreply to me...im interested to do the cgnos certifications relating to report developer.can you suggest me what kind of certifications andwhere cani get (dumps) previous quetions and answers for the certification........
Explain about scorecarding?
How to deploy from one server to another server?
What is a Pivot?
What is a Datastore in Cognos?
hi my name is siraj i want to know cognos queriy language
what are the filters in framework manager and report studio?
Synchroness 1.What are hash prompts? Ans: Tree prompts in which hierarchies can be seen,they can be said as hash prompts. 2.User wants to see 5 more coloums in the report.We have package and data base,how will u implement using it in report.? Ans: 3.What is automatic optimization?what is optimization?what are the properties you set for optimization in report studio? 4.what is command to display first 10 records from a table? IGATE 1.In FM if we change a fact symbol to attribute,will it effect the report? 2.If a report is slow in generating output. How do u perform tuning? How do u reduce joins in sql? Using left outer join is it going to improve the report performance? IBM 1.How do you configure ? 2.How do you drill through report from RS to Analysis studio?
What errors and types of errors you faced in Cognos ReportNet?
my report ended at the half of the last page but i don't want that matter in the last page I would like to adjust the matter in the previous page .how can i do this?
What are shortcuts? Where it can be used? What are the advantages?
What is model filter?
How can we create a dynamic column name in cognos?
what are the names of the reports that you prepared?