Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/sql-manual/sql-functions/window-functions/lag.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Returns the same data type as the input expression.

## Examples

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

Calculate the difference between each salesperson's current sales amount and the previous day's sales amount:

```sql
Expand Down
5 changes: 5 additions & 0 deletions docs/sql-manual/sql-functions/window-functions/lead.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Returns the same data type as the input expression.

## Examples

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

Calculate the difference between each salesperson's current sales and next day's sales:

```sql
Expand Down
5 changes: 5 additions & 0 deletions docs/sql-manual/sql-functions/window-functions/ntile.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ If a statement contains both an ORDER BY clause in the NTILE function and an ORD

## Examples

<!-- setup-sql
CREATE TABLE student_scores (name VARCHAR(20), score INT) DISTRIBUTED BY HASH(name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO student_scores VALUES ('Alice',98),('Bob',95),('Charlie',90),('David',85),('Eve',82),('Frank',78),('Grace',75),('Henry',70);
-->

```sql
SELECT
name,
Expand Down
5 changes: 5 additions & 0 deletions docs/sql-manual/sql-functions/window-functions/rank.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Returns a BIGINT rank value. Returns the same rank for identical values, but cre

## Examples

<!-- setup-sql
CREATE TABLE employees (department VARCHAR(20), employee_name VARCHAR(20), salary INT) DISTRIBUTED BY HASH(employee_name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO employees VALUES ('Sales','Alice',10000),('Sales','Bob',10000),('Sales','Charlie',8000),('IT','David',12000),('IT','Eve',11000),('IT','Frank',11000),('IT','Grace',9000);
-->

```sql
SELECT
department,
Expand Down
5 changes: 5 additions & 0 deletions docs/sql-manual/sql-functions/window-functions/row-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Returns a BIGINT sequence number, starting from 1 and incrementing continuously.

## Examples

<!-- setup-sql
CREATE TABLE int_t (x INT, y INT) DISTRIBUTED BY HASH(x) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO int_t VALUES (1,1),(1,2),(1,2),(2,1),(2,2),(2,3),(3,1),(3,1),(3,2);
-->

```sql
select x, y, row_number() over(partition by x order by y) as rank from int_t;
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ LAG ( <expr> [, <offset> [, <default> ] ] )

## 举例

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

计算每个销售员当前销售额与前一天销售额的差值:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ LEAD ( <expr> [ , <offset> [ , <default> ] ] )

## 举例

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

计算每个销售员当前销售额与下一天销售额的差值:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ NTILE( <constant_value> )

## 举例

<!-- setup-sql
CREATE TABLE student_scores (name VARCHAR(20), score INT) DISTRIBUTED BY HASH(name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO student_scores VALUES ('Alice',98),('Bob',95),('Charlie',90),('David',85),('Eve',82),('Frank',78),('Grace',75),('Henry',70);
-->

```sql
SELECT
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ RANK()

## 举例

<!-- setup-sql
CREATE TABLE employees (department VARCHAR(20), employee_name VARCHAR(20), salary INT) DISTRIBUTED BY HASH(employee_name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO employees VALUES ('Sales','Alice',10000),('Sales','Bob',10000),('Sales','Charlie',8000),('IT','David',12000),('IT','Eve',11000),('IT','Frank',11000),('IT','Grace',9000);
-->

```sql
SELECT
department,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ ROW_NUMBER()

## 举例

<!-- setup-sql
CREATE TABLE int_t (x INT, y INT) DISTRIBUTED BY HASH(x) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO int_t VALUES (1,1),(1,2),(1,2),(2,1),(2,2),(2,3),(3,1),(3,1),(3,2);
-->

```sql
select x, y, row_number() over(partition by x order by y) as rank from int_t;
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check notice on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-section-order

SQL function docs must contain sections in this order%3A Description%2C Syntax%2C Parameters%2C Return Value%2C Example. Missing%3A Example. Owner%3A @zclllyybb

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-title-duplicate

Rendered SEO title is duplicated across indexable pages%3A "LAG - Apache Doris". Add a version%2C locale%2C or page-specific qualifier. Owner%3A @zclllyybb

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-description-length

SEO description should be 80-160 characters; current length is 58. Owner%3A @zclllyybb
{
"title": "LAG",
"language": "zh-CN",
Expand All @@ -9,14 +9,14 @@
## 描述

LAG() 是一个窗口函数,用于访问当前行之前的行数据,而无需进行自连接。它可以获取分区内当前行之前第 N 行的值。

Check notice on line 12 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-parameters-table

Parameters section must be a Markdown table with Parameter and Description columns. Owner%3A @zclllyybb
## 语法

```sql
LAG ( <expr>, <offset>, <default> )
```

## 参数

Check notice on line 19 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-return-null

Return Value section must document NULL return conditions%2C including when the function never returns NULL. Owner%3A @zclllyybb
| 参数 | 说明 |
| ------------------- | ----------------------------------------------------------------- |
| expr | 需要获取值的表达式 |
Expand All @@ -29,6 +29,11 @@

## 举例

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

计算每个销售员当前销售额与前一天销售额的差值:

```sql
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check notice on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/lead.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-section-order

SQL function docs must contain sections in this order%3A Description%2C Syntax%2C Parameters%2C Return Value%2C Example. Missing%3A Example. Owner%3A @zclllyybb

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/lead.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-description-length

SEO description should be 80-160 characters; current length is 59. Owner%3A @zclllyybb
{
"title": "LEAD",
"language": "zh-CN",
Expand All @@ -9,14 +9,14 @@
## 描述

LEAD() 是一个窗口函数,用于访问当前行之后的行数据,而无需进行自连接。它可以获取分区内当前行之后第 N 行的值。

Check notice on line 12 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/lead.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-parameters-table

Parameters section must be a Markdown table with Parameter and Description columns. Owner%3A @zclllyybb
## 语法

```sql
LEAD ( <expr> [ , <offset> [ , <default> ] ] )
```

## 参数

Check notice on line 19 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/lead.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-return-null

Return Value section must document NULL return conditions%2C including when the function never returns NULL. Owner%3A @zclllyybb
| 参数 | 说明 |
| ------------------- | ----------------------------------------------------------------------------------------------------------------- |
| expr | 需要获取值的表达式 |
Expand All @@ -29,6 +29,11 @@

## 举例

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

计算每个销售员当前销售额与下一天销售额的差值:

```sql
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check notice on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/ntile.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-section-order

SQL function docs must contain sections in this order%3A Description%2C Syntax%2C Parameters%2C Return Value%2C Example. Missing%3A Example. Owner%3A @zclllyybb
{
"title": "NTILE",
"language": "zh-CN",
Expand All @@ -9,12 +9,12 @@
## 描述

NTILE() 是一个窗口函数,用于将有序数据集平均分配到指定数量的桶中。桶的编号从 1 开始顺序编号,直到指定的桶数。当数据无法平均分配时,优先将多出的记录分配给编号较小的桶,使得各个桶中的行数最多相差 1。

Check notice on line 12 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/ntile.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-parameters-table

Parameters section must be a Markdown table with Parameter and Description columns. Owner%3A @zclllyybb
## 语法

```sql
NTILE( <constant_value> )
```

Check notice on line 17 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/ntile.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-return-null

Return Value section must document NULL return conditions%2C including when the function never returns NULL. Owner%3A @zclllyybb

## 参数
| 参数 | 说明 |
Expand All @@ -33,6 +33,11 @@

## 举例

<!-- setup-sql
CREATE TABLE student_scores (name VARCHAR(20), score INT) DISTRIBUTED BY HASH(name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO student_scores VALUES ('Alice',98),('Bob',95),('Charlie',90),('David',85),('Eve',82),('Frank',78),('Grace',75),('Henry',70);
-->

```sql
SELECT
name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check notice on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/window-functions/rank.md

View workflow job for this annotation

GitHub Actions / Build Check

sql-function-section-order

SQL function docs must contain sections in this order%3A Description%2C Syntax%2C Parameters%2C Return Value%2C Example. Missing%3A Parameters%2C Example. Owner%3A @zclllyybb
{
"title": "RANK",
"language": "zh-CN",
Expand All @@ -22,6 +22,11 @@

## 举例

<!-- setup-sql
CREATE TABLE employees (department VARCHAR(20), employee_name VARCHAR(20), salary INT) DISTRIBUTED BY HASH(employee_name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO employees VALUES ('Sales','Alice',10000),('Sales','Bob',10000),('Sales','Charlie',8000),('IT','David',12000),('IT','Eve',11000),('IT','Frank',11000),('IT','Grace',9000);
-->

```sql
SELECT
department,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ ROW_NUMBER()

## 举例

<!-- setup-sql
CREATE TABLE int_t (x INT, y INT) DISTRIBUTED BY HASH(x) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO int_t VALUES (1,1),(1,2),(1,2),(2,1),(2,2),(2,3),(3,1),(3,1),(3,2);
-->

```sql
select x, y, row_number() over(partition by x order by y) as rank from int_t;
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-title-duplicate

Rendered SEO title is duplicated across indexable pages%3A "LAG - Apache Doris". Add a version%2C locale%2C or page-specific qualifier. Owner%3A @zclllyybb

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-description-length

SEO description should be 80-160 characters; current length is 58. Owner%3A @zclllyybb
{
"title": "LAG",
"language": "zh-CN",
Expand Down Expand Up @@ -29,6 +29,11 @@

## 举例

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

计算每个销售员当前销售额与前一天销售额的差值:

```sql
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/sql-manual/sql-functions/window-functions/lead.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-description-length

SEO description should be 80-160 characters; current length is 59. Owner%3A @zclllyybb
{
"title": "LEAD",
"language": "zh-CN",
Expand Down Expand Up @@ -29,6 +29,11 @@

## 举例

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

计算每个销售员当前销售额与下一天销售额的差值:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ NTILE( <constant_value> )

## 举例

<!-- setup-sql
CREATE TABLE student_scores (name VARCHAR(20), score INT) DISTRIBUTED BY HASH(name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO student_scores VALUES ('Alice',98),('Bob',95),('Charlie',90),('David',85),('Eve',82),('Frank',78),('Grace',75),('Henry',70);
-->

```sql
SELECT
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ RANK()

## 举例

<!-- setup-sql
CREATE TABLE employees (department VARCHAR(20), employee_name VARCHAR(20), salary INT) DISTRIBUTED BY HASH(employee_name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO employees VALUES ('Sales','Alice',10000),('Sales','Bob',10000),('Sales','Charlie',8000),('IT','David',12000),('IT','Eve',11000),('IT','Frank',11000),('IT','Grace',9000);
-->

```sql
SELECT
department,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ ROW_NUMBER()

## 举例

<!-- setup-sql
CREATE TABLE int_t (x INT, y INT) DISTRIBUTED BY HASH(x) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO int_t VALUES (1,1),(1,2),(1,2),(2,1),(2,2),(2,3),(3,1),(3,1),(3,2);
-->

```sql
select x, y, row_number() over(partition by x order by y) as rank from int_t;
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-title-duplicate

Rendered SEO title is duplicated across indexable pages%3A "LAG - Apache Doris". Add a version%2C locale%2C or page-specific qualifier. Owner%3A @zclllyybb
{
"title": "LAG",
"language": "zh-CN",
Expand Down Expand Up @@ -30,6 +30,11 @@

## 举例

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

计算每个销售员当前销售额与前一天销售额的差值:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ LEAD ( <expr> [ , <offset> [ , <default> ] ] )

## 举例

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

计算每个销售员当前销售额与下一天销售额的差值:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ NTILE( <constant_value> )

## 举例

<!-- setup-sql
CREATE TABLE student_scores (name VARCHAR(20), score INT) DISTRIBUTED BY HASH(name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO student_scores VALUES ('Alice',98),('Bob',95),('Charlie',90),('David',85),('Eve',82),('Frank',78),('Grace',75),('Henry',70);
-->

```sql
SELECT
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ RANK()

## 举例

<!-- setup-sql
CREATE TABLE employees (department VARCHAR(20), employee_name VARCHAR(20), salary INT) DISTRIBUTED BY HASH(employee_name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO employees VALUES ('Sales','Alice',10000),('Sales','Bob',10000),('Sales','Charlie',8000),('IT','David',12000),('IT','Eve',11000),('IT','Frank',11000),('IT','Grace',9000);
-->

```sql
SELECT
department,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ ROW_NUMBER()

## 举例

<!-- setup-sql
CREATE TABLE int_t (x INT, y INT) DISTRIBUTED BY HASH(x) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO int_t VALUES (1,1),(1,2),(1,2),(2,1),(2,2),(2,3),(3,1),(3,1),(3,2);
-->

```sql
select x, y, row_number() over(partition by x order by y) as rank from int_t;
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check warning on line 1 in versioned_docs/version-2.1/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-title-duplicate

Rendered SEO title is duplicated across indexable pages%3A "LAG - Apache Doris". Add a version%2C locale%2C or page-specific qualifier. Owner%3A @zclllyybb
{
"title": "LAG",
"language": "en",
Expand Down Expand Up @@ -29,6 +29,11 @@

## Examples

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

Calculate the difference between each salesperson's current sales amount and the previous day's sales amount:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Returns the same data type as the input expression.

## Examples

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

Calculate the difference between each salesperson's current sales and next day's sales:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ If a statement contains both an ORDER BY clause in the NTILE function and an ORD

## Examples

<!-- setup-sql
CREATE TABLE student_scores (name VARCHAR(20), score INT) DISTRIBUTED BY HASH(name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO student_scores VALUES ('Alice',98),('Bob',95),('Charlie',90),('David',85),('Eve',82),('Frank',78),('Grace',75),('Henry',70);
-->

```sql
SELECT
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Returns a BIGINT rank value. Returns the same rank for identical values, but cre

## Examples

<!-- setup-sql
CREATE TABLE employees (department VARCHAR(20), employee_name VARCHAR(20), salary INT) DISTRIBUTED BY HASH(employee_name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO employees VALUES ('Sales','Alice',10000),('Sales','Bob',10000),('Sales','Charlie',8000),('IT','David',12000),('IT','Eve',11000),('IT','Frank',11000),('IT','Grace',9000);
-->

```sql
SELECT
department,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Returns a BIGINT sequence number, starting from 1 and incrementing continuously.

## Examples

<!-- setup-sql
CREATE TABLE int_t (x INT, y INT) DISTRIBUTED BY HASH(x) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO int_t VALUES (1,1),(1,2),(1,2),(2,1),(2,2),(2,3),(3,1),(3,1),(3,2);
-->

```sql
select x, y, row_number() over(partition by x order by y) as rank from int_t;
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check warning on line 1 in versioned_docs/version-3.x/sql-manual/sql-functions/window-functions/lag.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-title-duplicate

Rendered SEO title is duplicated across indexable pages%3A "LAG - Apache Doris". Add a version%2C locale%2C or page-specific qualifier. Owner%3A @zclllyybb
{
"title": "LAG",
"language": "en",
Expand Down Expand Up @@ -29,6 +29,11 @@

## Examples

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

Calculate the difference between each salesperson's current sales amount and the previous day's sales amount:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Returns the same data type as the input expression.

## Examples

<!-- setup-sql
CREATE TABLE stock_ticker (stock_symbol VARCHAR(10), closing_date DATETIME, closing_price DOUBLE) DISTRIBUTED BY HASH(stock_symbol) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO stock_ticker VALUES ('JDR','2014-09-13 00:00:00',12.86),('JDR','2014-09-14 00:00:00',12.89),('JDR','2014-09-15 00:00:00',12.94),('JDR','2014-09-16 00:00:00',12.55),('JDR','2014-09-17 00:00:00',14.03),('JDR','2014-09-18 00:00:00',14.75),('JDR','2014-09-19 00:00:00',13.98);
-->

Calculate the difference between each salesperson's current sales and next day's sales:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ If a statement contains both an ORDER BY clause in the NTILE function and an ORD

## Examples

<!-- setup-sql
CREATE TABLE student_scores (name VARCHAR(20), score INT) DISTRIBUTED BY HASH(name) BUCKETS 1 PROPERTIES("replication_num"="1");
INSERT INTO student_scores VALUES ('Alice',98),('Bob',95),('Charlie',90),('David',85),('Eve',82),('Frank',78),('Grace',75),('Henry',70);
-->

```sql
SELECT
name,
Expand Down
Loading
Loading