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

Explain what is the difference between native sql and cognos sql?

1013


plsreply to me...im interested to do the cgnos certifications relating to report developer.can you suggest me what kind of certifications andwhere cani get (dumps) previous quetions and answers for the certification........

2357


Explain about scorecarding?

2083


How to deploy from one server to another server?

2502


What is a Pivot?

1157


What is a Datastore in Cognos?

1291


hi my name is siraj i want to know cognos queriy language

2274


what are the filters in framework manager and report studio?

996


Synchroness 1.What are hash prompts? Ans: Tree prompts in which hierarchies can be seen,they can be said as hash prompts. 2.User wants to see 5 more coloums in the report.We have package and data base,how will u implement using it in report.? Ans: 3.What is automatic optimization?what is optimization?what are the properties you set for optimization in report studio? 4.what is command to display first 10 records from a table? IGATE 1.In FM if we change a fact symbol to attribute,will it effect the report? 2.If a report is slow in generating output. How do u perform tuning? How do u reduce joins in sql? Using left outer join is it going to improve the report performance? IBM 1.How do you configure ? 2.How do you drill through report from RS to Analysis studio?

4751


What errors and types of errors you faced in Cognos ReportNet?

4195


my report ended at the half of the last page but i don't want that matter in the last page I would like to adjust the matter in the previous page .how can i do this?

2006


What are shortcuts? Where it can be used? What are the advantages?

1076


What is model filter?

1225


How can we create a dynamic column name in cognos?

961


what are the names of the reports that you prepared?

1113