Skip to content

Commit 60a66fc

Browse files
committed
fixes
1 parent d880cf5 commit 60a66fc

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

docs/en/sql-reference/20-sql-functions/08-window-functions/last-value.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ VALUES
4343

4444
-- Use LAST_VALUE to retrieve the first name of the employee with the lowest salary
4545
SELECT employee_id, first_name, last_name, salary,
46-
LAST_VALUE(first_name) OVER (ORDER BY salary DESC) AS lowest_salary_first_name
46+
LAST_VALUE(first_name) OVER (ORDER BY salary DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS lowest_salary_first_name
4747
FROM employees;
4848

49-
employee_id | first_name | last_name | salary | lowest_salary_first_name
50-
------------+------------+-----------+---------+------------------------
51-
4 | Mary | Williams | 7000.00 | Michael
52-
2 | Jane | Smith | 6000.00 | Michael
53-
3 | David | Johnson | 5500.00 | Michael
54-
1 | John | Doe | 5000.00 | Michael
55-
5 | Michael | Brown | 4500.00 | Michael
49+
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
50+
│ employee_id │ first_name │ last_name │ salary │ lowest_salary_first_name │
51+
├─────────────────┼──────────────────┼──────────────────┼──────────────────────────┼──────────────────────────┤
52+
4 │ Mary │ Williams │ 7000.00 │ Michael │
53+
2 │ Jane │ Smith │ 6000.00 │ Michael │
54+
3 │ David │ Johnson │ 5500.00 │ Michael │
55+
1 │ John │ Doe │ 5000.00 │ Michael │
56+
5 │ Michael │ Brown │ 4500.00 │ Michael │
57+
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
5658
```
5759

5860
This example excludes the NULL values from the window frame with the `IGNORE NULLS` option:

docs/en/sql-reference/20-sql-functions/08-window-functions/nth-value.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ VALUES
4343

4444
-- Use NTH_VALUE to retrieve the first name of the employee with the second highest salary
4545
SELECT employee_id, first_name, last_name, salary,
46-
NTH_VALUE(first_name, 2) OVER (ORDER BY salary DESC) AS second_highest_salary_first_name
46+
NTH_VALUE(first_name, 2) OVER (ORDER BY salary DESC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS second_highest_salary_first_name
4747
FROM employees;
4848

49-
employee_id | first_name | last_name | salary | second_highest_salary_first_name
50-
------------+------------+-----------+---------+----------------------------------
51-
4 | Mary | Williams | 7000.00 | Jane
52-
2 | Jane | Smith | 6000.00 | Jane
53-
3 | David | Johnson | 5500.00 | Jane
54-
1 | John | Doe | 5000.00 | Jane
55-
5 | Michael | Brown | 4500.00 | Jane
49+
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
50+
│ employee_id │ first_name │ last_name │ salary │ second_highest_salary_first_name │
51+
├─────────────────┼──────────────────┼──────────────────┼──────────────────────────┼──────────────────────────────────┤
52+
4 │ Mary │ Williams │ 7000.00 │ Jane │
53+
2 │ Jane │ Smith │ 6000.00 │ Jane │
54+
3 │ David │ Johnson │ 5500.00 │ Jane │
55+
1 │ John │ Doe │ 5000.00 │ Jane │
56+
5 │ Michael │ Brown │ 4500.00 │ Jane │
57+
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
5658
```
5759

5860
This example excludes the NULL values from the window frame with the `IGNORE NULLS` option:

0 commit comments

Comments
 (0)