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

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?

1975


Define catalog in cognos and write its various types?

1117


Cleared COG-112 with 100% score today. What next certification should i go for?

1785


What are the types of security?

963


how can you get the errors in job? when loops are araised we get error?

2057


what r the reports u faced critical and how it can be solved .. any once can u give a best ans for interviw

2252


what do u mean by bridge group? where we r using this one?

1900


What are products of cognos?

935


Explain informatica architecture?

935


Can you define cube?

972


what are the errors faced while bursting the reports and how to solve those errors?

1951


What is drill down and slicing and dicing whats the difference between them?

990


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.

2568


which type of project we r going to snowflake schema

1931


What are the types of folder present in cognos?

1049