Skip to content

Commit 1254b9f

Browse files
committed
TOP (N) updates bug fix
1 parent b47b316 commit 1254b9f

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

Instructions/Labs/02-filter-sort.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Sometimes you only want to return a specific number of rows. For example, you mi
6868
1. Modify the existing query to return the **Name** and **ListPrice** of all products:
6969
7070
```
71-
SELECT TOP 20 Name, ListPrice
71+
SELECT TOP (20) Name, ListPrice
7272
FROM SalesLT.Product
7373
ORDER BY ListPrice DESC;
7474
```
@@ -77,7 +77,7 @@ Sometimes you only want to return a specific number of rows. For example, you mi
7777
3. Modify the query to add the **WITH TIES** parameter as shown here, and re-run it.
7878
7979
```
80-
SELECT TOP 20 WITH TIES Name, ListPrice
80+
SELECT TOP (20) WITH TIES Name, ListPrice
8181
FROM SalesLT.Product
8282
ORDER BY ListPrice DESC;
8383
```
@@ -86,7 +86,7 @@ Sometimes you only want to return a specific number of rows. For example, you mi
8686
5. Modify the query to add the **PERCENT** parameter as shown here, and re-run it.
8787
8888
```
89-
SELECT TOP 20 PERCENT WITH TIES Name, ListPrice
89+
SELECT TOP (20) PERCENT WITH TIES Name, ListPrice
9090
FROM SalesLT.Product
9191
ORDER BY ListPrice DESC;
9292
```
@@ -302,7 +302,7 @@ This section contains suggested solutions for the challenge queries.
302302
2. Retrieve the heaviest products:
303303
304304
```
305-
SELECT TOP 10 PERCENT WITH TIES Name
305+
SELECT TOP (10) PERCENT WITH TIES Name
306306
FROM SalesLT.Product
307307
ORDER BY Weight DESC;
308308
```

Scripts/module02-demos.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ ORDER BY CountryRegion DESC, City ASC;
2323
-- TOP
2424

2525
-- Top records
26-
SELECT TOP 10 AddressLine1, ModifiedDate
26+
SELECT TOP (10) AddressLine1, ModifiedDate
2727
FROM SalesLT.Address
2828
ORDER BY ModifiedDate DESC;
2929

3030
-- Top with ties
31-
SELECT TOP 10 WITH TIES AddressLine1, ModifiedDate
31+
SELECT TOP (10) WITH TIES AddressLine1, ModifiedDate
3232
FROM SalesLT.Address
3333
ORDER BY ModifiedDate DESC;
3434

3535
-- Top percent
36-
SELECT TOP 10 PERCENT AddressLine1, ModifiedDate
36+
SELECT TOP (10) PERCENT AddressLine1, ModifiedDate
3737
FROM SalesLT.Address
3838
ORDER BY ModifiedDate DESC;
3939

Scripts/module04-demos.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ FROM SalesLT.SalesOrderHeader;
6666
-- RANKING Functions
6767

6868
-- Ranking
69-
SELECT TOP 100 ProductID, Name, ListPrice,
69+
SELECT TOP (100) ProductID, Name, ListPrice,
7070
RANK() OVER(ORDER BY ListPrice DESC) AS RankByPrice
7171
FROM SalesLT.Product AS p
7272
ORDER BY RankByPrice;

0 commit comments

Comments
 (0)