Pages - Menu

Thursday, November 22

SQL- Top clause

Top clause
This query incorporates a Top clause to limit the number of rows returned.
Now try this query on AdventureWorksDW2008

  • select FirstName, LastName, EnglishEducation, EnglishOccupation from DimCustomer


There are about 18484 rows returned with only four columns as specified. Now to limit by 3 rows see the below query.

  • select top 3 FirstName, LastName, EnglishEducation, EnglishOccupation from DimCustomer

Here only 3 rows are returned as specified. If applied on numeric columns, same is the result.

Note: Click to find Nth Highest Salary using Top clause.