Sql Select Top in MS SQL Server MS Access
Limiting result rows we use sql select top statement for MS SQL Server MS Access.
In this sql select top tutorial we will use the sample table below for our sql select top statement examples.
We will limit the result rows (records) in the users table with TOP.
Users Table; tbl_users
| id | Name | Password | Age | |
|---|---|---|---|---|
| 1 | John Doe | johndoe@j.com | e56Hdf-2 | 34 |
| 2 | Jane Doe | janedoe@j.com | p59Hdf-2 | 32 |
| 2 | Gary Doe | garydoe@j.com | y02Tdf-2 | 23 |
SQL Select Top Code
SELECT TOP 2 * FROM tbl_users
This sql query will return top 2 rows records from users table.
Query Result| id | Name | Password | Age | |
|---|---|---|---|---|
| 1 | John Doe | johndoe@j.com | e56Hdf-2 | 34 |
| 2 | Jane Doe | janedoe@j.com | p59Hdf-2 | 32 |
Note that you can also filter results by using WHERE in your sql top queries.
SELECT TOP in other databases: