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 you migrate reports to cognos 8 from previous versions?
How can I test reports in cagonos?
tell me two or three issues from client side and how to solve those issues?
Can you explain dynamic query mode?
What is the function of cognos dispatcher?
Hi Buddies...i am lalitha. i am willing to appear for cognos bi-author certification. can anyone of you send me cognos dump. please please help me.
What is the difference b/w macros and prompt?
faq's on cognos
What are all the types of indexes in Cognos?
Name the types of report?
----------------Describe DWH Architecture?
Define dimensions?
how u burst the reports? if u r bursted reports is not reached to destination how u identify???
What is zero-foot print?
what is the diff. between a link n a union? what is a custom view? what is the use of unlocking a report ? plz answer to these