English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

anyone give the sql?

2007-01-04 04:50:16 · 3 answers · asked by anjus 3 in Computers & Internet Programming & Design

I want a query which run in SQL Server 2000

2007-01-04 05:06:56 · update #1

I don't want the topmost 3 rows.I just want 3 persons who gets the highest salary.
for eg.2000,1000,3000,5000,750 r the salary.
I want to retrievt 2000,3000,5000 from the table.

2007-01-04 05:20:03 · update #2

3 answers

SELECT TOP 3 T_Employee.*
FROM T_Employee
ORDER BY T_Employee.Salary DESC;

Add TOP x following SELECT to return the first x records of your query.
ORDER BY decending (DESC) on the particular field in this case Salary. Above query will then return all fields in the records of the top 3 highest salaried employees.

2007-01-04 05:12:34 · answer #1 · answered by MarkG 7 · 0 0

The previous query was correct. If you sort your records by salary in decending order -- e.g., from highest to lowest -- then the top 3 records are the three highest salaries.

SELECT TOP 3 namecolumn FROM salarytable ORDER BY salarycolumn DESC

2007-01-04 13:56:59 · answer #2 · answered by Anonymous · 0 0

depends on your database but here goes:

select * from employee order by salary desc limit 3;

2007-01-04 13:03:03 · answer #3 · answered by Paul 2 · 0 1

fedest.com, questions and answers