This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new dce18cb325 [doc] Add window functions sql help doc (#9393)
dce18cb325 is described below

commit dce18cb3254ba1c81b44fcb6f5cd108de76a5560
Author: Mingyu Chen <morningman....@gmail.com>
AuthorDate: Sat May 7 08:43:51 2022 +0800

    [doc] Add window functions sql help doc (#9393)
---
 be/test/util/arrow/arrow_work_flow_test.cpp        |  6 +-
 docs/.vuepress/sidebar/en.js                       | 20 +++++
 docs/.vuepress/sidebar/zh-CN.js                    | 22 ++++-
 .../window-functions/WINDOW-FUNCTION-AVG.md        | 53 ++++++++++++
 .../window-functions/WINDOW-FUNCTION-COUNT.md      | 53 ++++++++++++
 .../window-functions/WINDOW-FUNCTION-DENSE-RANK.md | 45 ++++++++++
 .../WINDOW-FUNCTION-FIRST-VALUE.md                 | 60 +++++++++++++
 .../window-functions/WINDOW-FUNCTION-LAG.md        | 46 ++++++++++
 .../window-functions/WINDOW-FUNCTION-LAST-VALUE.md | 45 ++++++++++
 .../window-functions/WINDOW-FUNCTION-LEAD.md       | 51 +++++++++++
 .../window-functions/WINDOW-FUNCTION-MAX.md        | 49 +++++++++++
 .../window-functions/WINDOW-FUNCTION-MIN.md        | 48 +++++++++++
 .../window-functions/WINDOW-FUNCTION-RANK.md       | 45 ++++++++++
 .../window-functions/WINDOW-FUNCTION-ROW-NUMBER.md | 43 ++++++++++
 .../window-functions/WINDOW-FUNCTION-SUM.md        | 53 ++++++++++++
 .../window-functions/WINDOW-FUNCTION.md            | 99 ++++++++++++++++++++++
 .../window-functions/WINDOW-FUNCTION-AVG.md        | 53 ++++++++++++
 .../window-functions/WINDOW-FUNCTION-COUNT.md      | 53 ++++++++++++
 .../window-functions/WINDOW-FUNCTION-DENSE-RANK.md | 45 ++++++++++
 .../WINDOW-FUNCTION-FIRST-VALUE.md                 | 60 +++++++++++++
 .../window-functions/WINDOW-FUNCTION-LAG.md        | 46 ++++++++++
 .../window-functions/WINDOW-FUNCTION-LAST-VALUE.md | 45 ++++++++++
 .../window-functions/WINDOW-FUNCTION-LEAD.md       | 51 +++++++++++
 .../window-functions/WINDOW-FUNCTION-MAX.md        | 49 +++++++++++
 .../window-functions/WINDOW-FUNCTION-MIN.md        | 48 +++++++++++
 .../window-functions/WINDOW-FUNCTION-RANK.md       | 45 ++++++++++
 .../window-functions/WINDOW-FUNCTION-ROW-NUMBER.md | 43 ++++++++++
 .../window-functions/WINDOW-FUNCTION-SUM.md        | 53 ++++++++++++
 .../window-functions/WINDOW-FUNCTION.md            | 99 ++++++++++++++++++++++
 29 files changed, 1426 insertions(+), 2 deletions(-)

diff --git a/be/test/util/arrow/arrow_work_flow_test.cpp 
b/be/test/util/arrow/arrow_work_flow_test.cpp
index 2eb8fc2606..f04cc56b6c 100644
--- a/be/test/util/arrow/arrow_work_flow_test.cpp
+++ b/be/test/util/arrow/arrow_work_flow_test.cpp
@@ -65,7 +65,11 @@ protected:
         EXPECT_EQ(system("rm -rf ./test_run"), 0);
 
         delete _state;
-        doris::ExecEnv::destroy(_exec_env);
+        if (_exec_env) {
+            delete _exec_env->_result_queue_mgr;
+            delete _exec_env->_thread_mgr;
+            delete _exec_env->_buffer_reservation;
+        }
     }
 
     void init();
diff --git a/docs/.vuepress/sidebar/en.js b/docs/.vuepress/sidebar/en.js
index f073b098b9..54c9b78634 100644
--- a/docs/.vuepress/sidebar/en.js
+++ b/docs/.vuepress/sidebar/en.js
@@ -524,6 +524,26 @@ module.exports = [
               "outer-combinator"
             ],
           },
+          {
+            title: "Analytic(Window) Functions",
+            directoryPath: "window-functions/",
+            initialOpenGroupIndex: -1,
+            children: [
+              "WINDOW-FUNCTION",
+              "WINDOW-FUNCTION-SUM",
+              "WINDOW-FUNCTION-AVG",
+              "WINDOW-FUNCTION-COUNT",
+              "WINDOW-FUNCTION-MIN",
+              "WINDOW-FUNCTION-MAX",
+              "WINDOW-FUNCTION-LEAD",
+              "WINDOW-FUNCTION-LAG",
+              "WINDOW-FUNCTION-RANK",
+              "WINDOW-FUNCTION-DENSE-RANK",
+              "WINDOW-FUNCTION-FIRST-VALUE",
+              "WINDOW-FUNCTION-LAST-VALUE",
+              "WINDOW-FUNCTION-ROW-NUMBER",
+            ],
+          },
           "cast",
           "digital-masking",
         ],
diff --git a/docs/.vuepress/sidebar/zh-CN.js b/docs/.vuepress/sidebar/zh-CN.js
index 73aa561caf..dd5f6ceea6 100644
--- a/docs/.vuepress/sidebar/zh-CN.js
+++ b/docs/.vuepress/sidebar/zh-CN.js
@@ -514,7 +514,7 @@ module.exports = [
             ],
           },
           {
-            title: "table functions",
+            title: "表函数",
             directoryPath: "table-functions/",
             initialOpenGroupIndex: -1,
             children: [
@@ -524,6 +524,26 @@ module.exports = [
               "outer-combinator"
             ],
           },
+          {
+            title: "分析(窗口)函数",
+            directoryPath: "window-functions/",
+            initialOpenGroupIndex: -1,
+            children: [
+              "WINDOW-FUNCTION",
+              "WINDOW-FUNCTION-SUM",
+              "WINDOW-FUNCTION-AVG",
+              "WINDOW-FUNCTION-COUNT",
+              "WINDOW-FUNCTION-MIN",
+              "WINDOW-FUNCTION-MAX",
+              "WINDOW-FUNCTION-LEAD",
+              "WINDOW-FUNCTION-LAG",
+              "WINDOW-FUNCTION-RANK",
+              "WINDOW-FUNCTION-DENSE-RANK",
+              "WINDOW-FUNCTION-FIRST-VALUE",
+              "WINDOW-FUNCTION-LAST-VALUE",
+              "WINDOW-FUNCTION-ROW-NUMBER",
+            ],
+          },
           "cast",
           "digital-masking",
         ],
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-AVG.md 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-AVG.md
new file mode 100644
index 0000000000..c739e94a7c
--- /dev/null
+++ b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-AVG.md
@@ -0,0 +1,53 @@
+---
+{
+    "title": "WINDOW-FUNCTION-AVG",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION AVG
+### description
+
+Calculate the mean of the data within the window
+
+```sql
+AVG([DISTINCT | ALL] *expression*) [OVER (*analytic_clause*)]
+```
+
+### example
+
+Calculate the x-average of the current row and the rows before and after it
+
+```sql
+select x, property,    
+avg(x) over    
+(   
+partition by property    
+order by x    
+rows between 1 preceding and 1 following    
+) as 'moving average'    
+from int_t where property in ('odd','even');
+
+ | x  | property | moving average |
+ |----|----------|----------------|
+ | 2  | even     | 3              |
+ | 4  | even     | 4              |
+ | 6  | even     | 6              |
+ | 8  | even     | 8              |
+ | 10 | even     | 9              |
+ | 1  | odd      | 2              |
+ | 3  | odd      | 3              |
+ | 5  | odd      | 5              |
+ | 7  | odd      | 7              |
+ | 9  | odd      | 8              |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,AVG
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-COUNT.md 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-COUNT.md
new file mode 100644
index 0000000000..21d7cb25f8
--- /dev/null
+++ b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-COUNT.md
@@ -0,0 +1,53 @@
+---
+{
+    "title": "WINDOW-FUNCTION-COUNT",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION COUNT
+### description
+
+Count the number of occurrences of data in the window
+
+```sql
+COUNT([DISTINCT | ALL] expression) [OVER (analytic_clause)]
+```
+
+### example
+
+Count the number of occurrences of x from the current row to the first row.
+
+```sql
+select x, property,   
+count(x) over   
+(   
+partition by property    
+order by x    
+rows between unbounded preceding and current row    
+) as 'cumulative total'    
+from int_t where property in ('odd','even');
+
+ | x  | property | cumulative count |
+ |----|----------|------------------|
+ | 2  | even     | 1                |
+ | 4  | even     | 2                |
+ | 6  | even     | 3                |
+ | 8  | even     | 4                |
+ | 10 | even     | 5                |
+ | 1  | odd      | 1                |
+ | 3  | odd      | 2                |
+ | 5  | odd      | 3                |
+ | 7  | odd      | 4                |
+ | 9  | odd      | 5                |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,COUNT
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-DENSE-RANK.md
 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-DENSE-RANK.md
new file mode 100644
index 0000000000..66061a7ff8
--- /dev/null
+++ 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-DENSE-RANK.md
@@ -0,0 +1,45 @@
+---
+{
+    "title": "WINDOW-FUNCTION-DENSE_RANK",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION DENSE_RANK
+### description
+
+The DENSE_RANK() function is used to represent rankings. Unlike RANK(), 
DENSE_RANK() does not have vacancies. For example, if there are two parallel 
1s, the third number of DENSE_RANK() is still 2, and the third number of RANK() 
is 3.
+
+```sql
+DENSE_RANK() OVER(partition_by_clause order_by_clause)
+```
+
+### example
+
+Group by the property column to rank column x:
+
+```sql
+ select x, y, dense_rank() over(partition by x order by y) as rank from int_t;
+ 
+ | x  | y    | rank     |
+ |----|------|----------|
+ | 1  | 1    | 1        |
+ | 1  | 2    | 2        |
+ | 1  | 2    | 2        |
+ | 2  | 1    | 1        |
+ | 2  | 2    | 2        |
+ | 2  | 3    | 3        |
+ | 3  | 1    | 1        |
+ | 3  | 1    | 1        |
+ | 3  | 2    | 2        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,DENSE_RANK
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-FIRST-VALUE.md
 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-FIRST-VALUE.md
new file mode 100644
index 0000000000..484e01c1ee
--- /dev/null
+++ 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-FIRST-VALUE.md
@@ -0,0 +1,60 @@
+---
+{
+    "title": "WINDOW-FUNCTION-FIRST_VALUE",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION FIRST_VALUE
+### description
+
+FIRST_VALUE() returns the first value in the window's range.
+
+```sql
+FIRST_VALUE(expr) OVER(partition_by_clause order_by_clause [window_clause])
+```
+
+### example
+
+
+We have the following data
+
+```sql
+ select name, country, greeting from mail_merge;
+ 
+ | name    | country | greeting     |
+ |---------|---------|--------------|
+ | Pete    | USA     | Hello        |
+ | John    | USA     | Hi           |
+ | Boris   | Germany | Guten tag    |
+ | Michael | Germany | Guten morgen |
+ | Bjorn   | Sweden  | Hej          |
+ | Mats    | Sweden  | Tja          |
+```
+
+Use FIRST_VALUE() to group by country and return the value of the first 
greeting in each group:
+
+```sql
+select country, name,    
+first_value(greeting)    
+over (partition by country order by name, greeting) as greeting from 
mail_merge;
+
+| country | name    | greeting  |
+|---------|---------|-----------|
+| Germany | Boris   | Guten tag |
+| Germany | Michael | Guten tag |
+| Sweden  | Bjorn   | Hej       |
+| Sweden  | Mats    | Hej       |
+| USA     | John    | Hi        |
+| USA     | Pete    | Hi        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,FIRST_VALUE
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAG.md 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAG.md
new file mode 100644
index 0000000000..1dbda8295f
--- /dev/null
+++ b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAG.md
@@ -0,0 +1,46 @@
+---
+{
+    "title": "WINDOW-FUNCTION-LAG",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION LAG
+### description
+
+The LAG() method is used to calculate the value of the current line several 
lines ahead.
+
+```sql
+LAG(expr, offset, default) OVER (partition_by_clause order_by_clause)
+```
+
+### example
+
+Calculate the previous day's closing price
+
+```sql
+select stock_symbol, closing_date, closing_price,    
+lag(closing_price,1, 0) over (partition by stock_symbol order by closing_date) 
as "yesterday closing"   
+from stock_ticker   
+order by closing_date;
+
+| stock_symbol | closing_date        | closing_price | yesterday closing |
+|--------------|---------------------|---------------|-------------------|
+| JDR          | 2014-09-13 00:00:00 | 12.86         | 0                 |
+| JDR          | 2014-09-14 00:00:00 | 12.89         | 12.86             |
+| JDR          | 2014-09-15 00:00:00 | 12.94         | 12.89             |
+| JDR          | 2014-09-16 00:00:00 | 12.55         | 12.94             |
+| JDR          | 2014-09-17 00:00:00 | 14.03         | 12.55             |
+| JDR          | 2014-09-18 00:00:00 | 14.75         | 14.03             |
+| JDR          | 2014-09-19 00:00:00 | 13.98         | 14.75             |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,LAG
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAST-VALUE.md
 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAST-VALUE.md
new file mode 100644
index 0000000000..86addce4b5
--- /dev/null
+++ 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAST-VALUE.md
@@ -0,0 +1,45 @@
+---
+{
+    "title": "WINDOW-FUNCTION-LAST_VALUE",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION LAST_VALUE
+### description
+
+LAST_VALUE() returns the last value in the window range. Opposite of 
FIRST_VALUE() .
+
+```sql
+LAST_VALUE(expr) OVER(partition_by_clause order_by_clause [window_clause])
+```
+
+### example
+
+Using the data from the FIRST_VALUE() example:
+
+```sql
+select country, name,    
+last_value(greeting)   
+over (partition by country order by name, greeting) as greeting   
+from mail_merge;
+
+| country | name    | greeting     |
+|---------|---------|--------------|
+| Germany | Boris   | Guten morgen |
+| Germany | Michael | Guten morgen |
+| Sweden  | Bjorn   | Tja          |
+| Sweden  | Mats    | Tja          |
+| USA     | John    | Hello        |
+| USA     | Pete    | Hello        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,LAST_VALUE
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LEAD.md 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LEAD.md
new file mode 100644
index 0000000000..0eb27ff63c
--- /dev/null
+++ b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LEAD.md
@@ -0,0 +1,51 @@
+---
+{
+    "title": "WINDOW-FUNCTION-LEAD",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION LEAD
+### description
+
+The LEAD() method is used to calculate the value of the current line several 
lines backwards.
+
+```sql
+LEAD(expr, offset, default]) OVER (partition_by_clause order_by_clause)
+```
+
+### example
+
+Calculate the trend of the closing price of the second day compared with the 
closing price of the day, that is, the closing price of the second day is 
higher or lower than that of the day.
+
+```sql
+select stock_symbol, closing_date, closing_price,    
+case   
+(lead(closing_price,1, 0)   
+over (partition by stock_symbol order by closing_date)-closing_price) > 0   
+when true then "higher"   
+when false then "flat or lower"    
+end as "trending"   
+from stock_ticker    
+order by closing_date;
+
+| stock_symbol | closing_date        | closing_price | trending      |
+|--------------|---------------------|---------------|---------------|
+| JDR          | 2014-09-13 00:00:00 | 12.86         | higher        |
+| JDR          | 2014-09-14 00:00:00 | 12.89         | higher        |
+| JDR          | 2014-09-15 00:00:00 | 12.94         | flat or lower |
+| JDR          | 2014-09-16 00:00:00 | 12.55         | higher        |
+| JDR          | 2014-09-17 00:00:00 | 14.03         | higher        |
+| JDR          | 2014-09-18 00:00:00 | 14.75         | flat or lower |
+| JDR          | 2014-09-19 00:00:00 | 13.98         | flat or lower |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,LEAD
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MAX.md 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MAX.md
new file mode 100644
index 0000000000..96fb6d37fd
--- /dev/null
+++ b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MAX.md
@@ -0,0 +1,49 @@
+---
+{
+    "title": "WINDOW-FUNCTION-MAX",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION MAX
+### description
+
+The LEAD() method is used to calculate the maximum value within the window.
+
+```sql
+MAX([DISTINCT | ALL] expression) [OVER (analytic_clause)]
+```
+
+### example
+
+Calculate the maximum value from the first row to the row after the current row
+
+```sql
+select x, property,   
+max(x) over    
+(   
+order by property, x    
+rows between unbounded preceding and 1 following    
+) as 'local maximum'    
+from int_t where property in ('prime','square');
+
+| x | property | local maximum |
+|---|----------|---------------|
+| 2 | prime    | 3             |
+| 3 | prime    | 5             |
+| 5 | prime    | 7             |
+| 7 | prime    | 7             |
+| 1 | square   | 7             |
+| 4 | square   | 9             |
+| 9 | square   | 9             |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,MAX
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MIN.md 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MIN.md
new file mode 100644
index 0000000000..72b6680eb5
--- /dev/null
+++ b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MIN.md
@@ -0,0 +1,48 @@
+---
+{
+    "title": "WINDOW-FUNCTION-MIN",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION MIN
+### description
+
+The LEAD() method is used to calculate the minimum value within the window.
+
+```sql
+MAX([DISTINCT | ALL] expression) [OVER (analytic_clause)]
+```
+
+### example
+
+Calculate the minimum value from the first row to the row after the current row
+
+```sql
+select x, property,   
+min(x) over    
+(    
+order by property, x desc    
+rows between unbounded preceding and 1 following   
+) as 'local minimum'   
+from int_t where property in ('prime','square');
+| x | property | local minimum |
+|---|----------|---------------|
+| 7 | prime    | 5             |
+| 5 | prime    | 3             |
+| 3 | prime    | 2             |
+| 2 | prime    | 2             |
+| 9 | square   | 2             |
+| 4 | square   | 1             |
+| 1 | square   | 1             |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,MIN
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-RANK.md 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-RANK.md
new file mode 100644
index 0000000000..c5a1060d05
--- /dev/null
+++ b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-RANK.md
@@ -0,0 +1,45 @@
+---
+{
+    "title": "WINDOW-FUNCTION-RANK",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION RANK
+### description
+
+The RANK() function is used to represent rankings. Unlike DENSE_RANK(), RANK() 
will have vacancies. For example, if there are two 1s in a row, the third 
number in RANK() is 3, not 2.
+
+```sql
+RANK() OVER(partition_by_clause order_by_clause)
+```
+
+### example
+
+rank by x
+
+```sql
+select x, y, rank() over(partition by x order by y) as rank from int_t;
+
+| x  | y    | rank     |
+|----|------|----------|
+| 1  | 1    | 1        |
+| 1  | 2    | 2        |
+| 1  | 2    | 2        |
+| 2  | 1    | 1        |
+| 2  | 2    | 2        |
+| 2  | 3    | 3        |
+| 3  | 1    | 1        |
+| 3  | 1    | 1        |
+| 3  | 2    | 3        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,RANK
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-ROW-NUMBER.md
 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-ROW-NUMBER.md
new file mode 100644
index 0000000000..b8d60c6af4
--- /dev/null
+++ 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-ROW-NUMBER.md
@@ -0,0 +1,43 @@
+---
+{
+    "title": "WINDOW-FUNCTION-ROW_NUMBER",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION ROW_NUMBER
+### description
+
+Returns a continuously increasing integer starting from 1 for each row of each 
Partition. Unlike RANK() and DENSE_RANK(), the value returned by ROW_NUMBER() 
does not repeat or appear vacant, and is continuously incremented.
+
+```sql
+ROW_NUMBER() OVER(partition_by_clause order_by_clause)
+```
+
+### example
+
+```sql
+select x, y, row_number() over(partition by x order by y) as rank from int_t;
+
+| x | y    | rank     |
+|---|------|----------|
+| 1 | 1    | 1        |
+| 1 | 2    | 2        |
+| 1 | 2    | 3        |
+| 2 | 1    | 1        |
+| 2 | 2    | 2        |
+| 2 | 3    | 3        |
+| 3 | 1    | 1        |
+| 3 | 1    | 2        |
+| 3 | 2    | 3        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,ROW_NUMBER
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-SUM.md 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-SUM.md
new file mode 100644
index 0000000000..223a3fa820
--- /dev/null
+++ b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-SUM.md
@@ -0,0 +1,53 @@
+---
+{
+    "title": "WINDOW-FUNCTION-SUM",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION SUM
+### description
+
+Calculate the sum of the data in the window
+
+```sql
+SUM([DISTINCT | ALL] expression) [OVER (analytic_clause)]
+```
+
+### example
+
+Group by property, and calculate the sum of the x columns of the current row 
and the previous row within the group.
+
+```sql
+select x, property,   
+sum(x) over    
+(   
+partition by property   
+order by x   
+rows between 1 preceding and 1 following    
+) as 'moving total'    
+from int_t where property in ('odd','even');
+
+| x  | property | moving total |
+|----|----------|--------------|
+| 2  | even     | 6            |
+| 4  | even     | 12           |
+| 6  | even     | 18           |
+| 8  | even     | 24           |
+| 10 | even     | 18           |
+| 1  | odd      | 4            |
+| 3  | odd      | 9            |
+| 5  | odd      | 15           |
+| 7  | odd      | 21           |
+| 9  | odd      | 16           |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,SUM
\ No newline at end of file
diff --git 
a/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md 
b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md
new file mode 100644
index 0000000000..d26936378f
--- /dev/null
+++ b/docs/en/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md
@@ -0,0 +1,99 @@
+---
+{
+    "title": "WINDOW-FUNCTION",
+    "language": "en"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION
+### description
+
+Analytical functions(windown function) are a special class of built-in 
functions. Similar to aggregate functions, analytic functions also perform 
calculations on multiple input rows to obtain a data value. The difference is 
that the analytic function processes the input data within a specific window, 
rather than grouping calculations by group by. The data within each window can 
be sorted and grouped using the over() clause. The analytic function computes a 
single value for each row of th [...]
+
+The syntax of the analytic function:
+
+```sql
+function(args) OVER(partition_by_clause order_by_clause [window_clause])    
+partition_by_clause ::= PARTITION BY expr [, expr ...]    
+order_by_clause ::= ORDER BY expr [ASC | DESC] [, expr [ASC | DESC] ...]
+```
+
+#### Function
+
+Support Functions: AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), 
LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER(), SUM()
+
+#### PARTITION BY clause
+
+The Partition By clause is similar to Group By. It groups the input rows 
according to the specified column or columns, and rows with the same value will 
be grouped together.
+
+#### ORDER BY clause
+
+The Order By clause is basically the same as the outer Order By. It defines 
the order in which the input rows are sorted, and if Partition By is specified, 
Order By defines the order within each Partition grouping. The only difference 
from the outer Order By is that the Order By n (n is a positive integer) in the 
OVER clause is equivalent to doing nothing, while the outer Order By n means 
sorting according to the nth column.
+
+Example:
+
+This example shows adding an id column to the select list with values 1, 2, 3, 
etc., sorted by the date_and_time column in the events table.
+
+```sql
+SELECT   
+row_number() OVER (ORDER BY date_and_time) AS id,   
+c1, c2, c3, c4   
+FROM events;
+```
+
+#### Window clause
+
+The Window clause is used to specify an operation range for the analytical 
function, the current row is the criterion, and several rows before and after 
are used as the object of the analytical function operation. The methods 
supported by the Window clause are: AVG(), COUNT(), FIRST_VALUE(), LAST_VALUE() 
and SUM(). For MAX() and MIN(), the window clause can specify the starting 
range UNBOUNDED PRECEDING
+
+syntax:
+
+```sql
+ROWS BETWEEN [ { m | UNBOUNDED } PRECEDING | CURRENT ROW] [ AND [CURRENT ROW | 
{ UNBOUNDED | n } FOLLOWING] ]
+```
+
+### example
+
+Suppose we have the following stock data, the stock symbol is JDR, and the 
closing price is the closing price of each day.
+
+```sql
+create table stock_ticker (stock_symbol string, closing_price decimal(8,2), 
closing_date timestamp);    
+...load some data...    
+select * from stock_ticker order by stock_symbol, closing_date
+ | stock_symbol | closing_price | closing_date        |
+ |--------------|---------------|---------------------|
+ | JDR          | 12.86         | 2014-10-02 00:00:00 |
+ | JDR          | 12.89         | 2014-10-03 00:00:00 |
+ | JDR          | 12.94         | 2014-10-04 00:00:00 |
+ | JDR          | 12.55         | 2014-10-05 00:00:00 |
+ | JDR          | 14.03         | 2014-10-06 00:00:00 |
+ | JDR          | 14.75         | 2014-10-07 00:00:00 |
+ | JDR          | 13.98         | 2014-10-08 00:00:00 |
+```
+
+This query uses the analytic function to generate the column moving_average, 
whose value is the 3-day average price of the stock, that is, the three-day 
average price of the previous day, the current day, and the next day. The first 
day has no value for the previous day, and the last day does not have the value 
for the next day, so these two lines only calculate the average of the two 
days. Partition By does not play a role here, because all the data are JDR 
data, but if there is other s [...]
+
+```sql
+select stock_symbol, closing_date, closing_price,    
+avg(closing_price) over (partition by stock_symbol order by closing_date    
+rows between 1 preceding and 1 following) as moving_average    
+from stock_ticker;
+ | stock_symbol | closing_date        | closing_price | moving_average |
+ |--------------|---------------------|---------------|----------------|
+ | JDR          | 2014-10-02 00:00:00 | 12.86         | 12.87          |
+ | JDR          | 2014-10-03 00:00:00 | 12.89         | 12.89          |
+ | JDR          | 2014-10-04 00:00:00 | 12.94         | 12.79          |
+ | JDR          | 2014-10-05 00:00:00 | 12.55         | 13.17          |
+ | JDR          | 2014-10-06 00:00:00 | 14.03         | 13.77          |
+ | JDR          | 2014-10-07 00:00:00 | 14.75         | 14.25          |
+ | JDR          | 2014-10-08 00:00:00 | 13.98         | 14.36          |
+```
+
+### keywords
+
+    WINDOW,FUNCTION
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-AVG.md 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-AVG.md
new file mode 100644
index 0000000000..cd8e8a1295
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-AVG.md
@@ -0,0 +1,53 @@
+---
+{
+    "title": "WINDOW-FUNCTION-AVG",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION AVG
+### description
+
+计算窗口内数据的平均值
+
+```sql
+AVG([DISTINCT | ALL] *expression*) [OVER (*analytic_clause*)]
+```
+
+### example
+
+计算当前行和它前后各一行数据的x平均值
+
+```sql
+select x, property,    
+avg(x) over    
+(   
+partition by property    
+order by x    
+rows between 1 preceding and 1 following    
+) as 'moving average'    
+from int_t where property in ('odd','even');
+
+ | x  | property | moving average |
+ |----|----------|----------------|
+ | 2  | even     | 3              |
+ | 4  | even     | 4              |
+ | 6  | even     | 6              |
+ | 8  | even     | 8              |
+ | 10 | even     | 9              |
+ | 1  | odd      | 2              |
+ | 3  | odd      | 3              |
+ | 5  | odd      | 5              |
+ | 7  | odd      | 7              |
+ | 9  | odd      | 8              |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,AVG
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-COUNT.md 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-COUNT.md
new file mode 100644
index 0000000000..e09e619130
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-COUNT.md
@@ -0,0 +1,53 @@
+---
+{
+    "title": "WINDOW-FUNCTION-COUNT",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION COUNT
+### description
+
+计算窗口内数据出现次数
+
+```sql
+COUNT([DISTINCT | ALL] expression) [OVER (analytic_clause)]
+```
+
+### example
+
+计算从当前行到第一行x出现的次数。
+
+```sql
+select x, property,   
+count(x) over   
+(   
+partition by property    
+order by x    
+rows between unbounded preceding and current row    
+) as 'cumulative total'    
+from int_t where property in ('odd','even');
+
+ | x  | property | cumulative count |
+ |----|----------|------------------|
+ | 2  | even     | 1                |
+ | 4  | even     | 2                |
+ | 6  | even     | 3                |
+ | 8  | even     | 4                |
+ | 10 | even     | 5                |
+ | 1  | odd      | 1                |
+ | 3  | odd      | 2                |
+ | 5  | odd      | 3                |
+ | 7  | odd      | 4                |
+ | 9  | odd      | 5                |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,COUNT
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-DENSE-RANK.md
 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-DENSE-RANK.md
new file mode 100644
index 0000000000..04ebd7bbf8
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-DENSE-RANK.md
@@ -0,0 +1,45 @@
+---
+{
+    "title": "WINDOW-FUNCTION-DENSE_RANK",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION DENSE_RANK
+### description
+
+DENSE_RANK() 函数用来表示排名,与RANK()不同的是,DENSE_RANK() 
不会出现空缺数字。比如,如果出现了两个并列的1,DENSE_RANK() 的第三个数仍然是2,而RANK()的第三个数是3。
+
+```sql
+DENSE_RANK() OVER(partition_by_clause order_by_clause)
+```
+
+### example
+
+按照 property 列分组对x列排名:
+
+```sql
+ select x, y, dense_rank() over(partition by x order by y) as rank from int_t;
+ 
+ | x  | y    | rank     |
+ |----|------|----------|
+ | 1  | 1    | 1        |
+ | 1  | 2    | 2        |
+ | 1  | 2    | 2        |
+ | 2  | 1    | 1        |
+ | 2  | 2    | 2        |
+ | 2  | 3    | 3        |
+ | 3  | 1    | 1        |
+ | 3  | 1    | 1        |
+ | 3  | 2    | 2        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,DENSE_RANK
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-FIRST-VALUE.md
 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-FIRST-VALUE.md
new file mode 100644
index 0000000000..911891b19f
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-FIRST-VALUE.md
@@ -0,0 +1,60 @@
+---
+{
+    "title": "WINDOW-FUNCTION-FIRST_VALUE",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION FIRST_VALUE
+### description
+
+FIRST_VALUE() 返回窗口范围内的第一个值。
+
+```sql
+FIRST_VALUE(expr) OVER(partition_by_clause order_by_clause [window_clause])
+```
+
+### example
+
+
+我们有如下数据
+
+```sql
+ select name, country, greeting from mail_merge;
+ 
+ | name    | country | greeting     |
+ |---------|---------|--------------|
+ | Pete    | USA     | Hello        |
+ | John    | USA     | Hi           |
+ | Boris   | Germany | Guten tag    |
+ | Michael | Germany | Guten morgen |
+ | Bjorn   | Sweden  | Hej          |
+ | Mats    | Sweden  | Tja          |
+```
+
+使用 FIRST_VALUE(),根据 country 分组,返回每个分组中第一个 greeting 的值:
+
+```sql
+select country, name,    
+first_value(greeting)    
+over (partition by country order by name, greeting) as greeting from 
mail_merge;
+
+| country | name    | greeting  |
+|---------|---------|-----------|
+| Germany | Boris   | Guten tag |
+| Germany | Michael | Guten tag |
+| Sweden  | Bjorn   | Hej       |
+| Sweden  | Mats    | Hej       |
+| USA     | John    | Hi        |
+| USA     | Pete    | Hi        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,FIRST_VALUE
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAG.md 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAG.md
new file mode 100644
index 0000000000..106b19a317
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAG.md
@@ -0,0 +1,46 @@
+---
+{
+    "title": "WINDOW-FUNCTION-LAG",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION LAG
+### description
+
+LAG() 方法用来计算当前行向前数若干行的值。
+
+```sql
+LAG(expr, offset, default) OVER (partition_by_clause order_by_clause)
+```
+
+### example
+
+计算前一天的收盘价
+
+```sql
+select stock_symbol, closing_date, closing_price,    
+lag(closing_price,1, 0) over (partition by stock_symbol order by closing_date) 
as "yesterday closing"   
+from stock_ticker   
+order by closing_date;
+
+| stock_symbol | closing_date        | closing_price | yesterday closing |
+|--------------|---------------------|---------------|-------------------|
+| JDR          | 2014-09-13 00:00:00 | 12.86         | 0                 |
+| JDR          | 2014-09-14 00:00:00 | 12.89         | 12.86             |
+| JDR          | 2014-09-15 00:00:00 | 12.94         | 12.89             |
+| JDR          | 2014-09-16 00:00:00 | 12.55         | 12.94             |
+| JDR          | 2014-09-17 00:00:00 | 14.03         | 12.55             |
+| JDR          | 2014-09-18 00:00:00 | 14.75         | 14.03             |
+| JDR          | 2014-09-19 00:00:00 | 13.98         | 14.75             |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,LAG
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAST-VALUE.md
 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAST-VALUE.md
new file mode 100644
index 0000000000..26e930d0b4
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LAST-VALUE.md
@@ -0,0 +1,45 @@
+---
+{
+    "title": "WINDOW-FUNCTION-LAST_VALUE",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION LAST_VALUE
+### description
+
+LAST_VALUE() 返回窗口范围内的最后一个值。与 FIRST_VALUE() 相反。
+
+```sql
+LAST_VALUE(expr) OVER(partition_by_clause order_by_clause [window_clause])
+```
+
+### example
+
+使用FIRST_VALUE()举例中的数据:
+
+```sql
+select country, name,    
+last_value(greeting)   
+over (partition by country order by name, greeting) as greeting   
+from mail_merge;
+
+| country | name    | greeting     |
+|---------|---------|--------------|
+| Germany | Boris   | Guten morgen |
+| Germany | Michael | Guten morgen |
+| Sweden  | Bjorn   | Tja          |
+| Sweden  | Mats    | Tja          |
+| USA     | John    | Hello        |
+| USA     | Pete    | Hello        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,LAST_VALUE
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LEAD.md 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LEAD.md
new file mode 100644
index 0000000000..58b40de645
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-LEAD.md
@@ -0,0 +1,51 @@
+---
+{
+    "title": "WINDOW-FUNCTION-LEAD",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION LEAD
+### description
+
+LEAD() 方法用来计算当前行向后数若干行的值。
+
+```sql
+LEAD(expr, offset, default]) OVER (partition_by_clause order_by_clause)
+```
+
+### example
+
+计算第二天的收盘价对比当天收盘价的走势,即第二天收盘价比当天高还是低。
+
+```sql
+select stock_symbol, closing_date, closing_price,    
+case   
+(lead(closing_price,1, 0)   
+over (partition by stock_symbol order by closing_date)-closing_price) > 0   
+when true then "higher"   
+when false then "flat or lower"    
+end as "trending"   
+from stock_ticker    
+order by closing_date;
+
+| stock_symbol | closing_date        | closing_price | trending      |
+|--------------|---------------------|---------------|---------------|
+| JDR          | 2014-09-13 00:00:00 | 12.86         | higher        |
+| JDR          | 2014-09-14 00:00:00 | 12.89         | higher        |
+| JDR          | 2014-09-15 00:00:00 | 12.94         | flat or lower |
+| JDR          | 2014-09-16 00:00:00 | 12.55         | higher        |
+| JDR          | 2014-09-17 00:00:00 | 14.03         | higher        |
+| JDR          | 2014-09-18 00:00:00 | 14.75         | flat or lower |
+| JDR          | 2014-09-19 00:00:00 | 13.98         | flat or lower |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,LEAD
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MAX.md 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MAX.md
new file mode 100644
index 0000000000..a12605e41e
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MAX.md
@@ -0,0 +1,49 @@
+---
+{
+    "title": "WINDOW-FUNCTION-MAX",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION MAX
+### description
+
+LEAD() 方法用来计算窗口内的最大值。
+
+```sql
+MAX([DISTINCT | ALL] expression) [OVER (analytic_clause)]
+```
+
+### example
+
+计算从第一行到当前行之后一行的最大值
+
+```sql
+select x, property,   
+max(x) over    
+(   
+order by property, x    
+rows between unbounded preceding and 1 following    
+) as 'local maximum'    
+from int_t where property in ('prime','square');
+
+| x | property | local maximum |
+|---|----------|---------------|
+| 2 | prime    | 3             |
+| 3 | prime    | 5             |
+| 5 | prime    | 7             |
+| 7 | prime    | 7             |
+| 1 | square   | 7             |
+| 4 | square   | 9             |
+| 9 | square   | 9             |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,MAX
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MIN.md 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MIN.md
new file mode 100644
index 0000000000..b247c44554
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-MIN.md
@@ -0,0 +1,48 @@
+---
+{
+    "title": "WINDOW-FUNCTION-MIN",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION MIN
+### description
+
+LEAD() 方法用来计算窗口内的最小值。
+
+```sql
+MAX([DISTINCT | ALL] expression) [OVER (analytic_clause)]
+```
+
+### example
+
+计算从第一行到当前行之后一行的最小值
+
+```sql
+select x, property,   
+min(x) over    
+(    
+order by property, x desc    
+rows between unbounded preceding and 1 following   
+) as 'local minimum'   
+from int_t where property in ('prime','square');
+| x | property | local minimum |
+|---|----------|---------------|
+| 7 | prime    | 5             |
+| 5 | prime    | 3             |
+| 3 | prime    | 2             |
+| 2 | prime    | 2             |
+| 9 | square   | 2             |
+| 4 | square   | 1             |
+| 1 | square   | 1             |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,MIN
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-RANK.md 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-RANK.md
new file mode 100644
index 0000000000..421203b744
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-RANK.md
@@ -0,0 +1,45 @@
+---
+{
+    "title": "WINDOW-FUNCTION-RANK",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION RANK
+### description
+
+RANK() 函数用来表示排名,与 DENSE_RANK() 不同的是,RANK() 会出现空缺数字。比如,如果出现了两个并列的1, RANK() 
的第三个数就是3,而不是2。
+
+```sql
+RANK() OVER(partition_by_clause order_by_clause)
+```
+
+### example
+
+根据 x 进行排名
+
+```sql
+select x, y, rank() over(partition by x order by y) as rank from int_t;
+
+| x  | y    | rank     |
+|----|------|----------|
+| 1  | 1    | 1        |
+| 1  | 2    | 2        |
+| 1  | 2    | 2        |
+| 2  | 1    | 1        |
+| 2  | 2    | 2        |
+| 2  | 3    | 3        |
+| 3  | 1    | 1        |
+| 3  | 1    | 1        |
+| 3  | 2    | 3        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,RANK
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-ROW-NUMBER.md
 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-ROW-NUMBER.md
new file mode 100644
index 0000000000..a772264215
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-ROW-NUMBER.md
@@ -0,0 +1,43 @@
+---
+{
+    "title": "WINDOW-FUNCTION-ROW_NUMBER",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION ROW_NUMBER
+### description
+
+为每个 Partition 的每一行返回一个从1开始连续递增的整数。与 RANK() 和 DENSE_RANK() 不同的是,ROW_NUMBER() 
返回的值不会重复也不会出现空缺,是连续递增的。
+
+```sql
+ROW_NUMBER() OVER(partition_by_clause order_by_clause)
+```
+
+### example
+
+```sql
+select x, y, row_number() over(partition by x order by y) as rank from int_t;
+
+| x | y    | rank     |
+|---|------|----------|
+| 1 | 1    | 1        |
+| 1 | 2    | 2        |
+| 1 | 2    | 3        |
+| 2 | 1    | 1        |
+| 2 | 2    | 2        |
+| 2 | 3    | 3        |
+| 3 | 1    | 1        |
+| 3 | 1    | 2        |
+| 3 | 2    | 3        |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,ROW_NUMBER
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-SUM.md 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-SUM.md
new file mode 100644
index 0000000000..c4b8f274c4
--- /dev/null
+++ 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION-SUM.md
@@ -0,0 +1,53 @@
+---
+{
+    "title": "WINDOW-FUNCTION-SUM",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION SUM
+### description
+
+计算窗口内数据的和
+
+```sql
+SUM([DISTINCT | ALL] expression) [OVER (analytic_clause)]
+```
+
+### example
+
+按照 property 进行分组,在组内计算当前行以及前后各一行的x列的和。
+
+```sql
+select x, property,   
+sum(x) over    
+(   
+partition by property   
+order by x   
+rows between 1 preceding and 1 following    
+) as 'moving total'    
+from int_t where property in ('odd','even');
+
+| x  | property | moving total |
+|----|----------|--------------|
+| 2  | even     | 6            |
+| 4  | even     | 12           |
+| 6  | even     | 18           |
+| 8  | even     | 24           |
+| 10 | even     | 18           |
+| 1  | odd      | 4            |
+| 3  | odd      | 9            |
+| 5  | odd      | 15           |
+| 7  | odd      | 21           |
+| 9  | odd      | 16           |
+```
+
+### keywords
+
+    WINDOW,FUNCTION,SUM
\ No newline at end of file
diff --git 
a/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md 
b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md
new file mode 100644
index 0000000000..9babb61e9f
--- /dev/null
+++ b/docs/zh-CN/sql-manual/sql-functions/window-functions/WINDOW-FUNCTION.md
@@ -0,0 +1,99 @@
+---
+{
+    "title": "窗口函数",
+    "language": "zh-CN"
+}
+---
+
+<!--  Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with this work 
for additional information regarding copyright ownership.  The ASF licenses 
this file to you under the Apache License, Version 2.0 (the "License"); you may 
not use this file except in compliance with the License.  You may obtain a copy 
of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the 
License for the specific language governing permissions and limitations under 
the License. -->
+
+## WINDOW FUNCTION
+### description
+
+分析函数是一类特殊的内置函数。和聚合函数类似,分析函数也是对于多个输入行做计算得到一个数据值。不同的是,分析函数是在一个特定的窗口内对输入数据做处理,而不是按照
 group by 来分组计算。每个窗口内的数据可以用 over() 从句进行排序和分组。分析函数会对结果集的每一行计算出一个单独的值,而不是每个 group 
by 分组计算一个值。这种灵活的方式允许用户在 select 从句中增加额外的列,给用户提供了更多的机会来对结果集进行重新组织和过滤。分析函数只能出现在 
select 列表和最外层的 order by 从句中。在查询过程中,分析函数会在最后生效,就是说,在执行完 join,where 和 group by 
等操作之后再执行。分析函数在金融和科学计算领域经常被使用到,用来分析趋势、计算离群值以及对大量数据进行分桶分析等。
+
+分析函数的语法:
+
+```sql
+function(args) OVER(partition_by_clause order_by_clause [window_clause])    
+partition_by_clause ::= PARTITION BY expr [, expr ...]    
+order_by_clause ::= ORDER BY expr [ASC | DESC] [, expr [ASC | DESC] ...]
+```
+
+#### Function
+
+目前支持的 Function 包括 AVG(), COUNT(), DENSE_RANK(), FIRST_VALUE(), LAG(), 
LAST_VALUE(), LEAD(), MAX(), MIN(), RANK(), ROW_NUMBER() 和 SUM()。
+
+#### PARTITION BY从句
+
+Partition By 从句和 Group By 类似。它把输入行按照指定的一列或多列分组,相同值的行会被分到一组。
+
+#### ORDER BY从句
+
+Order By从句和外层的Order By基本一致。它定义了输入行的排列顺序,如果指定了 Partition By,则 Order By 定义了每个 
Partition 分组内的顺序。与外层 Order By 的唯一不同点是,OVER 从句中的 Order By n(n是正整数)相当于不做任何操作,而外层的 
Order By n表示按照第n列排序。
+
+举例:
+
+这个例子展示了在select列表中增加一个id列,它的值是1,2,3等等,顺序按照events表中的date_and_time列排序。
+
+```sql
+SELECT   
+row_number() OVER (ORDER BY date_and_time) AS id,   
+c1, c2, c3, c4   
+FROM events;
+```
+
+#### Window从句
+
+Window 从句用来为分析函数指定一个运算范围,以当前行为准,前后若干行作为分析函数运算的对象。Window 从句支持的方法有:AVG(), 
COUNT(), FIRST_VALUE(), LAST_VALUE() 和 SUM()。对于 MAX() 和 MIN(), window 
从句可以指定开始范围 UNBOUNDED PRECEDING
+
+语法:
+
+```sql
+ROWS BETWEEN [ { m | UNBOUNDED } PRECEDING | CURRENT ROW] [ AND [CURRENT ROW | 
{ UNBOUNDED | n } FOLLOWING] ]
+```
+
+### example
+
+假设我们有如下的股票数据,股票代码是 JDR,closing price 是每天的收盘价。
+
+```sql
+create table stock_ticker (stock_symbol string, closing_price decimal(8,2), 
closing_date timestamp);    
+...load some data...    
+select * from stock_ticker order by stock_symbol, closing_date
+ | stock_symbol | closing_price | closing_date        |
+ |--------------|---------------|---------------------|
+ | JDR          | 12.86         | 2014-10-02 00:00:00 |
+ | JDR          | 12.89         | 2014-10-03 00:00:00 |
+ | JDR          | 12.94         | 2014-10-04 00:00:00 |
+ | JDR          | 12.55         | 2014-10-05 00:00:00 |
+ | JDR          | 14.03         | 2014-10-06 00:00:00 |
+ | JDR          | 14.75         | 2014-10-07 00:00:00 |
+ | JDR          | 13.98         | 2014-10-08 00:00:00 |
+```
+
+这个查询使用分析函数产生 moving_average 
这一列,它的值是3天的股票均价,即前一天、当前以及后一天三天的均价。第一天没有前一天的值,最后一天没有后一天的值,所以这两行只计算了两天的均值。这里 
Partition By 没有起到作用,因为所有的数据都是 JDR 的数据,但如果还有其他股票信息,Partition By 会保证分析函数值作用在本 
Partition 之内。
+
+```sql
+select stock_symbol, closing_date, closing_price,    
+avg(closing_price) over (partition by stock_symbol order by closing_date    
+rows between 1 preceding and 1 following) as moving_average    
+from stock_ticker;
+ | stock_symbol | closing_date        | closing_price | moving_average |
+ |--------------|---------------------|---------------|----------------|
+ | JDR          | 2014-10-02 00:00:00 | 12.86         | 12.87          |
+ | JDR          | 2014-10-03 00:00:00 | 12.89         | 12.89          |
+ | JDR          | 2014-10-04 00:00:00 | 12.94         | 12.79          |
+ | JDR          | 2014-10-05 00:00:00 | 12.55         | 13.17          |
+ | JDR          | 2014-10-06 00:00:00 | 14.03         | 13.77          |
+ | JDR          | 2014-10-07 00:00:00 | 14.75         | 14.25          |
+ | JDR          | 2014-10-08 00:00:00 | 13.98         | 14.36          |
+```
+
+### keywords
+
+    WINDOW,FUNCTION
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to