Skip to content

Commit 8c5a9fc

Browse files
committed
Updated SQL content, pull request syntax updates
1 parent 4878436 commit 8c5a9fc

File tree

1 file changed

+15
-5
lines changed
  • content/sql/concepts/commands/terms/top

1 file changed

+15
-5
lines changed

content/sql/concepts/commands/terms/top/top.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ Subjects:
77
Tags:
88
- 'Database'
99
- 'Queries'
10-
- 'T-SQL'
11-
- 'Transact-SQL'
10+
- 'SQL Server'
1211
CatalogContent:
1312
- 'learn-sql'
1413
- 'paths/analyze-data-with-sql'
@@ -18,21 +17,32 @@ Returns a specified number of rows from the top of the result.
1817

1918
## Syntax
2019

20+
This command is used to select the inital rows from a table, limiting the result to a specified number, represented here by (n):
21+
2122
```sql
22-
SELECT TOP (10) column_name(s)
23+
SELECT TOP (n) column_name(s)
2324
FROM table_name;
2425
```
2526

27+
The command can also be used with PERCENT to limit the result to the top (n) percent of rows:
28+
2629
```sql
27-
SELECT TOP (25) PERCENT column_name(s)
30+
SELECT TOP (n) PERCENT column_name(s)
2831
FROM table_name;
2932
```
3033

31-
## Example
34+
## Examples
3235

3336
The given query will display the top 5 rows from the `books` table.
3437

3538
```sql
3639
SELECT TOP (5) *
3740
FROM books;
3841
```
42+
43+
The given query will display the top 25% of rows from the `films` table.
44+
45+
```sql
46+
SELECT TOP (25) PERCENT movie_titles
47+
FROM movies;
48+
```

0 commit comments

Comments
 (0)