Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is metric store database?

990


----------------Describe DWH Architecture?

2057


how to explain tne project at the time of interview? where to start and how to end? plz explain in detail thax in advance

2081


What are the methods by which it non-durable model could be changed into the durable model?

942


What are query items?

1006


How can I schedule reports in cognos?

994


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

2120


Can you explain new content durability?

1012


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?

2056


WHAT IS METRIC STUDIO?WHAT IS SCORE CARDS HOW TO IMPLEMENT IT AND WHAT IS THE USE OF SCORE CARD?

6882


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?

1989


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.

2096


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?

2035


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..

1924


what is the use of backward drilling in cognos 8?is it possible?whats the uws of it?

2052