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

Find top Nth employee from each department in terms of
salary?

Answer Posted / chandra sekhar

CREATE A EMPLOYEES TABLE WITH THE COLUMNS
EMPLOYEEID,EMPLOYEENAME,DEPARTMENT,SALARY
AND INSERT THE RECORDS INTO THE TABLE

with cte
as (
select dense_RANK() over(partition by department order by salary desc) as Rank,
employeeID,employeename,department,salary from
Employees)
select x.employeeID,
x.employeename,
x.department,
x.salary,
x.rank
from cte x
where x.Rank=2
order by x.Salary


NOTE:here i am finding 2nd highest salary from the each department

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the concept of view and Types of views in SQL server?

944


What are data regions?

121


Explain data warehousing in sql server?

991


optimization techinques

2637


Can you give me some DBCC command options?(Database consistency check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any damage.

2467


What are the advantages of using third-party tools?

921


What is row_number () and partition by in sql server?

1007


What is mean by candidate key?

949


How many triggers are possible per table?

1040


explain different types of joins? : Sql server database administration

924


Explain the concept of recursive stored procedure.

885


What are types of subqueries?

997


when would you go for denormalization? : Sql server database administration

813


What is service broker? : sql server database administration

942


What have included columns when we talk about sql server indexing?

992