SQL Select Top

Table: Employees

EmployeeId FirstName LastName Department Salary
203 Mary Fox Finance 78000
204 Joe Lanyon Finance 45800
205 Sally Daff Finance 57000
206 Grace Salter Finance 62000
302 James Band Development 75000
303 Dona Earl Development 55000
304 Tony Oakes Development 49000

SQL Server

SQL Select Top 10 rows:

SELECT TOP 10 *
FROM Employees

SQL Select top 5 records of highest salary:

SELECT TOP 5 *
FROM Employees
ORDER BY Salary DESC

SQL Select top 5 percent of highest salary:

SELECT TOP 5 PERCENT *
FROM Employees
ORDER BY Salary DESC
MySQL

SQL Select first 10 rows of highest salary:

SELECT *
FROM Employees
ORDER BY Salary DESC
LIMIT 10
Oracle

SQL Select first record:

SELECT *
FROM Employees
WHERE ROWNUM <= 1

SQL Select first 100 record of highest salary:

SELECT *
FROM
  (
     SELECT * 
     FROM Employees
     ORDER BY Salary DESC
  )
WHERE ROWNUM <= 100

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>