Locked lesson.
About this lesson
The TOP clause is used to limit the number of records that will be returned from a SELECT statement
Exercise files
Download this lesson’s related exercise files.
TOP Clause.docx58.8 KB TOP Clause - Solution.docx
59.4 KB
Quick reference
TOP Clause
The Top clause lets us limit the number of records we return in a SQL Statement.
When to use
Use it any time you want to limit the number of records you return with your SQL Statement.
Instructions
The top clause looks like this:
SELECT TOP 100 [First Name], [Last Name]
FROM [Customer].[dbo].[Current_Customers]
This will return the top 100 records in your customer database. You can change the number '100' to what you want, e.g. Top 5 or Top 20 Percent.
Hints & tips
- TOP can specify an exact number or a percentage
- To use percentages with TOP, use the word PERCENT (not the % sign)
Lesson notes are only available for subscribers.