select top 5 salaired employee

  • hi

    select top 5 salaired employee

    thanxs

     

  • SELECT TOP 5 * FROM dbo.Employee ORDER BY Salary_Col  DESC

    Prasad Bhogadi
    www.inforaise.com

  • You can use also something like this:

    SELECT  TOP 5 MAX(salary_col) AS MaxSalary, Employee_ID

    FROM   employee_salaray

    GROUP BY employee_id

    ORDER BY MAX(Salary_Col) DESC 

  • Do you have a table where the employees have more than one salary???

    Where do I send my resume .

     

    I would seriously consider query one unless you have a very special design!!

  • I think there can be employee with different salary but they would have different effectivity dates. Going along the lines here is the query that gets looks at the employee's most current pay rate and gets the top 5. You can exclude "InActive" employees by adding a where clause.

    Select Top 5 EmployeeSalaray.EmployeeID,EmployeeSalaray.Salary,EmployeeSalaray.EffectiveDate

    from EmployeeSalaray INNER JOIN

    (Select EmployeeID,Max(EffectiveDate) as MaxEffectiveDate

     from EmployeeSalaray

     group by EmployeeID) MaxSal on EmployeeSalaray.EmployeeID = MaxSal.EmployeeID

      and EmployeeSalaray.EffectiveDate = MaxSal.MaxEffectiveDate

    order by EmployeeSalaray.Salary

    Thanks

    Sreejith

  • Your solution makes sense and depending on the modelling of the database the best required solution can be put to use.

    Thx

    Prasad Bhogadi
    www.inforaise.com

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply