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
What is metric store database?
----------------Describe DWH Architecture?
how to explain tne project at the time of interview? where to start and how to end? plz explain in detail thax in advance
What are the methods by which it non-durable model could be changed into the durable model?
What are query items?
How can I schedule reports in cognos?
1.WHAT IS XML SPECIFICATION WHAT IS PURPOSE,WHERE YOU ARE GOING TO USE.2 DIFFERENCE BETWEEN RENDER VARIABLE AND CONDITIONAL BLOCK.3.WHAT IS LINK AND SEGMENT.4.WHAT IS CONDITIONAL LAYOUT.5. DIFFERENCE BETWEEN DETAIL FILTER AND SUMMERY FILTER AND HOW YOU ARE GOING DEFINE IN SQL (DETAIL AND SUMMARY FILTER ).. WELL THESE QUESTION I BEEN FACED IN IBM COULD SOMEBODY GET SOLUTIONS PLZ..THANKS IN ADVANCE
Can you explain new content durability?
I have 7500 rows. I need all rows in single reports. Which type of prompt we have used retrieving all rows and show in a report? We have dynamical queries q1, q2, q3, q4, q5. If customer selects the particular, query that only show in execution report. In case it may more then one, how do you execute the particular query item in report page? What are the difference bt OLDP and OLAP?
WHAT IS METRIC STUDIO?WHAT IS SCORE CARDS HOW TO IMPLEMENT IT AND WHAT IS THE USE OF SCORE CARD?
I have ten columns that needs to be totalled... but some columns are empty...how do i get sum all the columns even if sum are empty? Can i get a total of the rows instead of columns? if yes, what is the function to be used?
If we are migrating lower version of Cognos reports (e.g. from Ver 7.0 to Cognos 8) then how we migrate Impromptu Catalog (ver 7.0) in Cognos 8? Do we create FM model for that? Please explain.
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?
How can reports be bursted based on two groups? I want to schedule to burst a report based on product line and years and I need the burst report for every product line and every year. How can this be done? Please help..
what is the use of backward drilling in cognos 8?is it possible?whats the uws of it?