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 you migrate reports to cognos 8 from previous versions?

1096


How can I test reports in cagonos?

1012


tell me two or three issues from client side and how to solve those issues?

2214


Can you explain dynamic query mode?

1103


What is the function of cognos dispatcher?

1271


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.

1895


What is the difference b/w macros and prompt?

1219


faq's on cognos

4097


What are all the types of indexes in Cognos?

1300


Name the types of report?

1010


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

2104


Define dimensions?

1063


how u burst the reports? if u r bursted reports is not reached to destination how u identify???

11849


What is zero-foot print?

1084


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

2061