You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2021/09/22 03:14:36 UTC

[iotdb] 06/06: fix dml doc format

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

rong pushed a commit to branch nested-operations
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit aa9ad5e98ea232974c5ab3b9dc7e8737ed671d63
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Wed Sep 22 11:13:37 2021 +0800

    fix dml doc format
---
 .../DML-Data-Manipulation-Language.md              |  380 +++---
 .../DML-Data-Manipulation-Language.md              | 1242 ++++++++++----------
 2 files changed, 815 insertions(+), 807 deletions(-)

diff --git a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index d5ec200..17ac0b8 100644
--- a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -514,7 +514,7 @@ All supported aggregation functions are: count, sum, avg, last_value, first_valu
 When using four aggregations: sum, avg, min_value, max_value and extreme please make sure all the aggregated series have exactly the same data type.
 Otherwise, it will generate a syntax error.
 
-### Down-Frequency Aggregate Query
+#### Down-Frequency Aggregate Query
 
 This section mainly introduces the related examples of down-frequency aggregation query, 
 using the [GROUP BY clause](../Appendix/SQL-Reference.md), 
@@ -540,7 +540,7 @@ and value filtering conditions specified.
 
 **Figure 5.2 The actual meanings of the three types of parameters**
 
-#### Down-Frequency Aggregate Query without Specifying the Sliding Step Length
+##### Down-Frequency Aggregate Query without Specifying the Sliding Step Length
 
 The SQL statement is:
 
@@ -575,7 +575,7 @@ Total line number = 7
 It costs 0.024s
 ```
 
-#### Down-Frequency Aggregate Query Specifying the Sliding Step Length
+##### Down-Frequency Aggregate Query Specifying the Sliding Step Length
 
 The SQL statement is:
 
@@ -615,7 +615,7 @@ Total line number = 7
 It costs 0.006s
 ```
 
-#### Down-Frequency Aggregate Query by Natural Month
+##### Down-Frequency Aggregate Query by Natural Month
 
 The SQL statement is:
 
@@ -703,7 +703,7 @@ The SQL execution result is:
 +-----------------------------+-------------------------------+
 ```
 
-#### Left Open And Right Close Range
+##### Left Open And Right Close Range
 
 The SQL statement is:
 
@@ -731,62 +731,6 @@ Total line number = 7
 It costs 0.004s
 ```
 
-
-#### Down-Frequency Aggregate Query with Level Clause
-
-Level could be defined to show count the number of points of each node at the given level in current Metadata Tree.
-
-This could be used to query the number of points under each device.
-
-The SQL statement is:
-
-Get down-frequency aggregate query by level.
-
-```sql
-select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d), level=1;
-```
-Result:
-
-```
-+-----------------------------+-------------------------+
-|                         Time|COUNT(root.ln.*.*.status)|
-+-----------------------------+-------------------------+
-|2017-11-02T00:00:00.000+08:00|                     1440|
-|2017-11-03T00:00:00.000+08:00|                     1440|
-|2017-11-04T00:00:00.000+08:00|                     1440|
-|2017-11-05T00:00:00.000+08:00|                     1440|
-|2017-11-06T00:00:00.000+08:00|                     1440|
-|2017-11-07T00:00:00.000+08:00|                     1440|
-|2017-11-07T23:00:00.000+08:00|                     1380|
-+-----------------------------+-------------------------+
-Total line number = 7
-It costs 0.006s
-```
-
-Down-frequency aggregate query with sliding step and by level.
-
-```sql
-select count(status) from root.ln.wf01.wt01 group by ([2017-11-01 00:00:00, 2017-11-07 23:00:00), 3h, 1d), level=1;
-```
-
-Result:
-
-```
-+-----------------------------+-------------------------+
-|                         Time|COUNT(root.ln.*.*.status)|
-+-----------------------------+-------------------------+
-|2017-11-01T00:00:00.000+08:00|                      180|
-|2017-11-02T00:00:00.000+08:00|                      180|
-|2017-11-03T00:00:00.000+08:00|                      180|
-|2017-11-04T00:00:00.000+08:00|                      180|
-|2017-11-05T00:00:00.000+08:00|                      180|
-|2017-11-06T00:00:00.000+08:00|                      180|
-|2017-11-07T00:00:00.000+08:00|                      180|
-+-----------------------------+-------------------------+
-Total line number = 7
-It costs 0.004s
-```
-
 #### Down-Frequency Aggregate Query with Fill Clause
 
 In group by fill, sliding step is not supported in group by clause
@@ -796,7 +740,7 @@ Now, only last_value aggregation function is supported in group by fill.
 Linear fill is not supported in group by fill.
 
 
-##### Difference Between PREVIOUSUNTILLAST And PREVIOUS
+Difference Between PREVIOUSUNTILLAST And PREVIOUS:
 
 * PREVIOUS will fill any null value as long as there exist value is not null before it.
 * PREVIOUSUNTILLAST won't fill the result whose time is after the last time of that time series.
@@ -833,6 +777,7 @@ SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50
 ```
 
 result:
+
 ```
 +-----------------------------+-----------------------------------------+
 |                         Time|last_value(root.ln.wf01.wt01.temperature)|
@@ -875,139 +820,67 @@ which means:
 
 using PREVIOUSUNTILLAST won't fill time after 2017-11-07T23:59.
 
-### Last point Query
-
-In scenarios when IoT devices updates data in a fast manner, users are more interested in the most recent point of IoT devices.
-
-The Last point query is to return the most recent data point of the given timeseries in a three column format.
-
-The SQL statement is defined as:
-
-```sql
-select last <Path> [COMMA <Path>]* from < PrefixPath > [COMMA < PrefixPath >]* <WhereClause>
-```
-
-which means: Query and return the last data points of timeseries prefixPath.path.
-
-Only time filter with '>' or '>=' is supported in \<WhereClause\>. Any other filters given in the \<WhereClause\> will give an exception.
-
-The result will be returned in a four column table format.
-
-```
-| Time | timeseries | value | dataType |
-```
-
-Example 1: get the last point of root.ln.wf01.wt01.status:
-
-```
-IoTDB> select last status from root.ln.wf01.wt01
-+-----------------------------+------------------------+-----+--------+
-|                         Time|              timeseries|value|dataType|
-+-----------------------------+------------------------+-----+--------+
-|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.status|false| BOOLEAN|
-+-----------------------------+------------------------+-----+--------+
-Total line number = 1
-It costs 0.000s
-```
-
-Example 2: get the last status and temperature points of root.ln.wf01.wt01,
-whose timestamp larger or equal to 2017-11-07T23:50:00。
-
-```
-IoTDB> select last status, temperature from root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
-+-----------------------------+-----------------------------+---------+--------+
-|                         Time|                   timeseries|    value|dataType|
-+-----------------------------+-----------------------------+---------+--------+
-|2017-11-07T23:59:00.000+08:00|     root.ln.wf01.wt01.status|    false| BOOLEAN|
-|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.temperature|21.067368|  DOUBLE|
-+-----------------------------+-----------------------------+---------+--------+
-Total line number = 2
-It costs 0.002s
-```
-
-### Fuzzy query
+#### Down-Frequency Aggregate Query with Level Clause
 
-Fuzzy query is divided into Like statement and Regexp statement, both of which can support fuzzy matching of TEXT type data.
+Level could be defined to show count the number of points of each node at the given level in current Metadata Tree.
 
-Like statement:
+This could be used to query the number of points under each device.
 
-Example 1: Query data containing `'cc'` in `value` under `root.sg.device`. 
-The percentage (`%`) wildcard matches any string of zero or more characters.
+The SQL statement is:
 
+Get down-frequency aggregate query by level.
 
+```sql
+select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d), level=1;
 ```
-IoTDB> select * from root.sg.device where value like '%cc%'
-+-----------------------------+--------------------+
-|                         Time|root.sg.device.value|
-+-----------------------------+--------------------+
-|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
-|2017-11-07T23:59:00.000+08:00|                  cc|
-+-----------------------------+--------------------+
-Total line number = 2
-It costs 0.002s
-```
+Result:
 
-Example 2: Query data that consists of 3 characters and the second character is `'b'` in `value` under `root.sg.device`.
-The underscore (`_`) wildcard matches any single character.
 ```
-IoTDB> select * from root.sg.device where value like '_b_'
-+-----------------------------+--------------------+
-|                         Time|root.sg.device.value|
-+-----------------------------+--------------------+
-|2017-11-07T23:59:00.000+08:00|                 abc| 
-+-----------------------------+--------------------+
-Total line number = 1
-It costs 0.002s
++-----------------------------+-------------------------+
+|                         Time|COUNT(root.ln.*.*.status)|
++-----------------------------+-------------------------+
+|2017-11-02T00:00:00.000+08:00|                     1440|
+|2017-11-03T00:00:00.000+08:00|                     1440|
+|2017-11-04T00:00:00.000+08:00|                     1440|
+|2017-11-05T00:00:00.000+08:00|                     1440|
+|2017-11-06T00:00:00.000+08:00|                     1440|
+|2017-11-07T00:00:00.000+08:00|                     1440|
+|2017-11-07T23:00:00.000+08:00|                     1380|
++-----------------------------+-------------------------+
+Total line number = 7
+It costs 0.006s
 ```
 
-Regexp statement:
-
-The filter conditions that need to be passed in are regular expressions in the Java standard library style
-
-Example 1: Query a string composed of 26 English characters for the value under root.sg.device
-```
-IoTDB> select * from root.sg.device where value regexp '^[A-Za-z]+$'
-+-----------------------------+--------------------+
-|                         Time|root.sg.device.value|
-+-----------------------------+--------------------+
-|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
-|2017-11-07T23:59:00.000+08:00|                  cc|
-+-----------------------------+--------------------+
-Total line number = 2
-It costs 0.002s
-```
+Down-frequency aggregate query with sliding step and by level.
 
-Example 2: Query root.sg.device where the value value is a string composed of 26 lowercase English characters and the time is greater than 100
-```
-IoTDB> select * from root.sg.device where value regexp '^[a-z]+$' and time > 100
-+-----------------------------+--------------------+
-|                         Time|root.sg.device.value|
-+-----------------------------+--------------------+
-|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
-|2017-11-07T23:59:00.000+08:00|                  cc|
-+-----------------------------+--------------------+
-Total line number = 2
-It costs 0.002s
+```sql
+select count(status) from root.ln.wf01.wt01 group by ([2017-11-01 00:00:00, 2017-11-07 23:00:00), 3h, 1d), level=1;
 ```
 
-Examples of common regular matching:
+Result:
 
 ```
-All characters with a length of 3-20: ^.{3,20}$
-Uppercase english characters: ^[A-Z]+$
-Numbers and English characters: ^[A-Za-z0-9]+$
-Beginning with a: ^a.*
++-----------------------------+-------------------------+
+|                         Time|COUNT(root.ln.*.*.status)|
++-----------------------------+-------------------------+
+|2017-11-01T00:00:00.000+08:00|                      180|
+|2017-11-02T00:00:00.000+08:00|                      180|
+|2017-11-03T00:00:00.000+08:00|                      180|
+|2017-11-04T00:00:00.000+08:00|                      180|
+|2017-11-05T00:00:00.000+08:00|                      180|
+|2017-11-06T00:00:00.000+08:00|                      180|
+|2017-11-07T00:00:00.000+08:00|                      180|
++-----------------------------+-------------------------+
+Total line number = 7
+It costs 0.004s
 ```
 
-For more syntax description, please read [SQL Reference](../Appendix/SQL-Reference.md).
 ### Automated Fill
 
 In the actual use of IoTDB, when doing the query operation of timeseries, situations where the value is null at some time points may appear, which will obstruct the further analysis by users. In order to better reflect the degree of data change, users expect missing values to be automatically filled. Therefore, the IoTDB system introduces the function of Automated Fill.
 
 Automated fill function refers to filling empty values according to the user's specified method and effective time range when performing timeseries queries for single or multiple columns. If the queried point's value is not null, the fill function will not work.
 
-> Note: In the current version, IoTDB provides users with two methods: Previous and Linear. The previous method fills blanks with previous value. The linear method fills blanks through linear fitting. And the fill function can only be used when performing point-in-time queries.
-
 #### Fill Function
 
 * Previous Function
@@ -1181,6 +1054,151 @@ When the fill method is not specified, each data type bears its own default fill
 
 > Note: In version 0.7.0, at least one fill method should be specified in the Fill statement.
 
+### Last point Query
+
+In scenarios when IoT devices updates data in a fast manner, users are more interested in the most recent point of IoT devices.
+
+The Last point query is to return the most recent data point of the given timeseries in a three column format.
+
+The SQL statement is defined as:
+
+```sql
+select last <Path> [COMMA <Path>]* from < PrefixPath > [COMMA < PrefixPath >]* <WhereClause>
+```
+
+which means: Query and return the last data points of timeseries prefixPath.path.
+
+Only time filter with '>' or '>=' is supported in \<WhereClause\>. Any other filters given in the \<WhereClause\> will give an exception.
+
+The result will be returned in a four column table format.
+
+```
+| Time | timeseries | value | dataType |
+```
+
+Example 1: get the last point of root.ln.wf01.wt01.status:
+
+```
+IoTDB> select last status from root.ln.wf01.wt01
++-----------------------------+------------------------+-----+--------+
+|                         Time|              timeseries|value|dataType|
++-----------------------------+------------------------+-----+--------+
+|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.status|false| BOOLEAN|
++-----------------------------+------------------------+-----+--------+
+Total line number = 1
+It costs 0.000s
+```
+
+Example 2: get the last status and temperature points of root.ln.wf01.wt01,
+whose timestamp larger or equal to 2017-11-07T23:50:00。
+
+```
+IoTDB> select last status, temperature from root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
++-----------------------------+-----------------------------+---------+--------+
+|                         Time|                   timeseries|    value|dataType|
++-----------------------------+-----------------------------+---------+--------+
+|2017-11-07T23:59:00.000+08:00|     root.ln.wf01.wt01.status|    false| BOOLEAN|
+|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.temperature|21.067368|  DOUBLE|
++-----------------------------+-----------------------------+---------+--------+
+Total line number = 2
+It costs 0.002s
+```
+
+### Fuzzy query
+
+Fuzzy query is divided into Like statement and Regexp statement, both of which can support fuzzy matching of TEXT type data.
+
+Like statement:
+
+Example 1: Query data containing `'cc'` in `value` under `root.sg.device`. 
+The percentage (`%`) wildcard matches any string of zero or more characters.
+
+
+```
+IoTDB> select * from root.sg.device where value like '%cc%'
++-----------------------------+--------------------+
+|                         Time|root.sg.device.value|
++-----------------------------+--------------------+
+|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
+|2017-11-07T23:59:00.000+08:00|                  cc|
++-----------------------------+--------------------+
+Total line number = 2
+It costs 0.002s
+```
+
+Example 2: Query data that consists of 3 characters and the second character is `'b'` in `value` under `root.sg.device`.
+The underscore (`_`) wildcard matches any single character.
+
+```
+IoTDB> select * from root.sg.device where value like '_b_'
++-----------------------------+--------------------+
+|                         Time|root.sg.device.value|
++-----------------------------+--------------------+
+|2017-11-07T23:59:00.000+08:00|                 abc| 
++-----------------------------+--------------------+
+Total line number = 1
+It costs 0.002s
+```
+
+Regexp statement:
+
+The filter conditions that need to be passed in are regular expressions in the Java standard library style
+
+Example 1: Query a string composed of 26 English characters for the value under root.sg.device
+
+```
+IoTDB> select * from root.sg.device where value regexp '^[A-Za-z]+$'
++-----------------------------+--------------------+
+|                         Time|root.sg.device.value|
++-----------------------------+--------------------+
+|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
+|2017-11-07T23:59:00.000+08:00|                  cc|
++-----------------------------+--------------------+
+Total line number = 2
+It costs 0.002s
+```
+
+Example 2: Query root.sg.device where the value value is a string composed of 26 lowercase English characters and the time is greater than 100
+
+```
+IoTDB> select * from root.sg.device where value regexp '^[a-z]+$' and time > 100
++-----------------------------+--------------------+
+|                         Time|root.sg.device.value|
++-----------------------------+--------------------+
+|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
+|2017-11-07T23:59:00.000+08:00|                  cc|
++-----------------------------+--------------------+
+Total line number = 2
+It costs 0.002s
+```
+
+Examples of common regular matching:
+
+```
+All characters with a length of 3-20: ^.{3,20}$
+Uppercase english characters: ^[A-Z]+$
+Numbers and English characters: ^[A-Za-z0-9]+$
+Beginning with a: ^a.*
+```
+
+For more syntax description, please read [SQL Reference](../Appendix/SQL-Reference.md).
+
+### Alias
+
+Since the unique data model of IoTDB, lots of additional information like device will be carried before each sensor. Sometimes, we want to query just one specific device, then these prefix information show frequently will be redundant in this situation, influencing the analysis of result set. At this time, we can use `AS` function provided by IoTDB, assign an alias to time series selected in query.  
+
+For example:
+
+```sql
+select s1 as temperature, s2 as speed from root.ln.wf01.wt01;
+```
+
+The result set is:
+
+| Time | temperature | speed |
+| ---- | ----------- | ----- |
+| ...  | ...         | ...   |
+
 ### Row and Column Control over Query Results
 
 IoTDB provides [LIMIT/SLIMIT](../Appendix/SQL-Reference.md) clause and [OFFSET/SOFFSET](../Appendix/SQL-Reference.md) 
@@ -1541,7 +1559,7 @@ The SQL statement will not be executed and the corresponding error prompt is giv
 Msg: 411: Meet error in query process: The value of SOFFSET (2) is equal to or exceeds the number of sequences (2) that can actually be returned.
 ```
 
-#### Null Value Control over Query Results
+### Null Value Control over Query Results
 
 * IoTDB will join all the sensor value by its time, and if some sensors don't have values in that timestamp, we will fill it with null. In some analysis scenarios, we only need the row if all the columns of it have value.
 
@@ -1555,22 +1573,6 @@ select * from root.ln.* where time <= 2017-11-01T00:01:00 WITHOUT NULL ANY
 select * from root.ln.* where time <= 2017-11-01T00:01:00 WITHOUT NULL ALL
 ```
 
-### Use Alias
-
-Since the unique data model of IoTDB, lots of additional information like device will be carried before each sensor. Sometimes, we want to query just one specific device, then these prefix information show frequently will be redundant in this situation, influencing the analysis of result set. At this time, we can use `AS` function provided by IoTDB, assign an alias to time series selected in query.  
-
-For example:
-
-```sql
-select s1 as temperature, s2 as speed from root.ln.wf01.wt01;
-```
-
-The result set is:
-
-| Time | temperature | speed |
-| ---- | ----------- | ----- |
-| ...  | ...         | ...   |
-
 ### Other ResultSet Formats
 
 In addition, IoTDB supports two other results set format: 'align by device' and 'disable align'.
diff --git a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index 8ae15ff..fdd21dc 100644
--- a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -35,7 +35,7 @@ IoTDB 为用户提供多种插入实时数据的方式,例如在 [Cli/Shell 
 
 单列数据插入示例代码如下:
 
-```
+```sql
 IoTDB > insert into root.ln.wf02.wt02(timestamp,status) values(1,true)
 IoTDB > insert into root.ln.wf02.wt02(timestamp,hardware) values(1, "v1")
 ```
@@ -46,19 +46,19 @@ IoTDB > insert into root.ln.wf02.wt02(timestamp,hardware) values(1, "v1")
 
 INSERT 语句还可以支持在同一个时间点下多列数据的插入,同时向 2 时间点插入上述两个时间序列的值,多列数据插入示例代码如下:
 
-```
+```sql
 IoTDB > insert into root.ln.wf02.wt02(timestamp, status, hardware) values (2, false, 'v2')
 ```
 
 此外,INSERT 语句支持一次性插入多行数据,同时向 2 个不同时间点插入上述时间序列的值,示例代码如下:
 
-```
+```sql
 IoTDB > insert into root.ln.wf02.wt02(timestamp, status, hardware) VALUES (3, false, 'v3'),(4, true, 'v4')
 ```
 
 插入数据后我们可以使用 SELECT 语句简单查询已插入的数据。
 
-```
+```sql
 IoTDB > select * from root.ln.wf02 where time < 5
 ```
 
@@ -83,11 +83,11 @@ It costs 0.170s
 
 本节主要介绍时间切片查询的相关示例,主要使用的是 [IoTDB SELECT 语句](../Appendix/SQL-Reference.md)。同时,您也可以使用 [Java JDBC](../API/Programming-JDBC.md) 标准接口来执行相关的查询语句。
 
- * 根据一个时间区间选择一列数据
+#### 根据一个时间区间选择一列数据
 
 SQL 语句为:
 
-```
+```sql
 select temperature from root.ln.wf01.wt01 where time < 2017-11-01T00:08:00.000
 ```
 
@@ -114,11 +114,11 @@ Total line number = 8
 It costs 0.026s
 ```
 
- * 根据一个时间区间选择多列数据
+#### 根据一个时间区间选择多列数据
 
 SQL 语句为:
 
-```
+```sql
 select status, temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000;
 ```
 
@@ -143,13 +143,13 @@ Total line number = 6
 It costs 0.018s
 ```
 
- * 按照多个时间区间选择同一设备的多列数据
+#### 按照多个时间区间选择同一设备的多列数据
 
 IoTDB 支持在一次查询中指定多个时间区间条件,用户可以根据需求随意组合时间区间条件。例如,
 
 SQL 语句为:
 
-```
+```sql
 select status,temperature from root.ln.wf01.wt01 where (time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000) or (time >= 2017-11-01T16:35:00.000 and time <= 2017-11-01T16:37:00.000);
 ```
 
@@ -177,11 +177,11 @@ Total line number = 9
 It costs 0.018s
 ```
 
- * 按照多个时间区间选择不同设备的多列数据
+#### 按照多个时间区间选择不同设备的多列数据
 
 该系统支持在一次查询中选择任意列的数据,也就是说,被选择的列可以来源于不同的设备。例如,SQL 语句为:
 
-```
+```sql
 select wf01.wt01.status,wf02.wt02.hardware from root.ln where (time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000) or (time >= 2017-11-01T16:35:00.000 and time <= 2017-11-01T16:37:00.000);
 ```
 
@@ -209,13 +209,13 @@ Total line number = 9
 It costs 0.014s
 ```
 
-### 其他结果对齐方式
-
- * 根据时间降序返回
+#### 根据时间降序返回结果集
 IoTDB 在 0.11 版本开始支持 'order by time' 语句,用于对结果按照时间进行降序展示。例如,SQL 语句为:
+
 ```sql
 select * from root.ln where time > 1 order by time desc limit 10;
 ```
+
 语句执行的结果为:
 
 ```
@@ -239,77 +239,211 @@ It costs 0.016s
 
 更多语法请参照 [SQL REFERENCE](../Appendix/SQL-Reference.md).
 
- * IoTDB 支持另外两种结果返回形式:按设备时间对齐 'align by device' 和 时序不对齐 'disable align'.
+### 算数运算查询
 
-'align by device' 对齐方式下,设备 ID 会单独作为一列出现。在 select 子句中写了多少列,最终结果就会有该列数+2 (时间列和设备名字列)。SQL 形如:
+#### 一元算数运算符
 
-```
-select * from root.ln.* where time <= 2017-11-01T00:01:00 align by device
-```
-结果如下:
+支持的运算符:`+`, `-`
+
+输入数据类型要求:`INT32`, `INT64`, `FLOAT`和 `DOUBLE`
+
+输出数据类型:与输入数据类型一致
+
+#### 二元算数运算符
+
+支持的运算符:`+`, `-`, `*`, `/`,  `%`
 
+输入数据类型要求:`INT32`, `INT64`, `FLOAT`和 `DOUBLE`
+
+输出数据类型:`DOUBLE`
+
+注意:当某个时间戳下左操作数和右操作数都不为空(`null`)时,二元运算操作才会有输出结果
+
+#### 示例
+
+例如:
+
+```sql
+select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1
 ```
-+-----------------------------+-----------------+-----------+------+--------+
-|                         Time|           Device|temperature|status|hardware|
-+-----------------------------+-----------------+-----------+------+--------+
-|2017-11-01T00:00:00.000+08:00|root.ln.wf01.wt01|      25.96|  true|    null|
-|2017-11-01T00:01:00.000+08:00|root.ln.wf01.wt01|      24.36|  true|    null|
-|1970-01-01T08:00:00.001+08:00|root.ln.wf02.wt02|       null|  true|      v1|
-|1970-01-01T08:00:00.002+08:00|root.ln.wf02.wt02|       null| false|      v2|
-|2017-11-01T00:00:00.000+08:00|root.ln.wf02.wt02|       null|  true|      v2|
-|2017-11-01T00:01:00.000+08:00|root.ln.wf02.wt02|       null|  true|      v2|
-+-----------------------------+-----------------+-----------+------+--------+
-Total line number = 6
-It costs 0.012s
+
+结果:
+
+``` 
++-----------------------------+-------------+--------------+-------------+-------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+
+|                         Time|root.sg.d1.s1|-root.sg.d1.s1|root.sg.d1.s2|root.sg.d1.s2|root.sg.d1.s1 + root.sg.d1.s2|root.sg.d1.s1 - root.sg.d1.s2|root.sg.d1.s1 * root.sg.d1.s2|root.sg.d1.s1 / root.sg.d1.s2|root.sg.d1.s1 % root.sg.d1.s2|
++-----------------------------+-------------+--------------+-------------+-------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+
+|1970-01-01T08:00:00.001+08:00|          1.0|          -1.0|          1.0|          1.0|                          2.0|                          0.0|                          1.0|                          1.0|                          0.0|
+|1970-01-01T08:00:00.002+08:00|          2.0|          -2.0|          2.0|          2.0|                          4.0|                          0.0|                          4.0|                          1.0|                          0.0|
+|1970-01-01T08:00:00.003+08:00|          3.0|          -3.0|          3.0|          3.0|                          6.0|                          0.0|                          9.0|                          1.0|                          0.0|
+|1970-01-01T08:00:00.004+08:00|          4.0|          -4.0|          4.0|          4.0|                          8.0|                          0.0|                         16.0|                          1.0|                          0.0|
+|1970-01-01T08:00:00.005+08:00|          5.0|          -5.0|          5.0|          5.0|                         10.0|                          0.0|                         25.0|                          1.0|                          0.0|
++-----------------------------+-------------+--------------+-------------+-------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+
+Total line number = 5
+It costs 0.014s
 ```
 
-'disable align' 意味着每条时序就有 2 列存在。Disable Align 只能用于查询语句句尾,不能用于聚合查询、Fill 语句、Group by 或 Group by device 语句,但可用于 Limit 语句。结果显示若无数据显示为空白。
+### 内置时间序列生成函数
 
-SQL 形如:
+时间序列生成函数可接受若干原始时间序列作为输入,产生一列时间序列输出。与聚合函数不同的是,时间序列生成函数的结果集带有时间戳列。
+
+所有的时间序列生成函数都可以接受 * 作为输入,都可以与原始查询混合进行。
+
+#### 数学函数
+
+目前 IoTDB 支持下列数学函数,这些数学函数的行为与这些函数在 Java Math 标准库中对应实现的行为一致。
+
+| 函数名  | 输入序列类型                   | 输出序列类型             | Java 标准库中的对应实现                                      |
+| ------- | ------------------------------ | ------------------------ | ------------------------------------------------------------ |
+| SIN     | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#sin(double)                                             |
+| COS     | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#cos(double)                                             |
+| TAN     | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#tan(double)                                             |
+| ASIN    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#asin(double)                                            |
+| ACOS    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#acos(double)                                            |
+| ATAN    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#atan(double)                                            |
+| SINH    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#sinh(double)                                            |
+| COSH    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#cosh(double)                                            |
+| TANH    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#tanh(double)                                            |
+| DEGREES | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#toDegrees(double)                                       |
+| RADIANS | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#toRadians(double)                                       |
+| ABS     | INT32 / INT64 / FLOAT / DOUBLE | 与输入序列的实际类型一致 | Math#abs(int) / Math#abs(long) /Math#abs(float) /Math#abs(double) |
+| SIGN    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#signum(double)                                          |
+| CEIL    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#ceil(double)                                            |
+| FLOOR   | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#floor(double)                                           |
+| ROUND   | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#rint(double)                                            |
+| EXP     | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#exp(double)                                             |
+| LN      | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#log(double)                                             |
+| LOG10   | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#log10(double)                                           |
+| SQRT    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#sqrt(double)                                            |
+
+例如:
+
+```   sql
+select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000;
+```
+
+结果:
 
 ```
-select * from root.ln.* where time <= 2017-11-01T00:01:00 disable align
++-----------------------------+-------------------+-------------------+--------------------+-------------------+
+|                         Time|     root.sg1.d1.s1|sin(root.sg1.d1.s1)| cos(root.sg1.d1.s1)|tan(root.sg1.d1.s1)|
++-----------------------------+-------------------+-------------------+--------------------+-------------------+
+|2020-12-10T17:11:49.037+08:00|7360723084922759782| 0.8133527237573284|  0.5817708713544664| 1.3980636773094157|
+|2020-12-10T17:11:49.038+08:00|4377791063319964531|-0.8938962705202537|  0.4482738644511651| -1.994085181866842|
+|2020-12-10T17:11:49.039+08:00|7972485567734642915| 0.9627757585308978|-0.27030138509681073|-3.5618602479083545|
+|2020-12-10T17:11:49.040+08:00|2508858212791964081|-0.6073417341629443| -0.7944406950452296| 0.7644897069734913|
+|2020-12-10T17:11:49.041+08:00|2817297431185141819|-0.8419358900502509| -0.5395775727782725| 1.5603611649667768|
++-----------------------------+-------------------+-------------------+--------------------+-------------------+
+Total line number = 5
+It costs 0.008s
 ```
 
-结果如下:
+#### 字符串函数
+
+目前 IoTDB 支持下列字符串处理函数:
+
+| 函数名          | 输入序列类型 | 必要的属性参数                       | 输出序列类型 | 功能描述                                  |
+| --------------- | ------------ | ------------------------------------ | ------------ | ----------------------------------------- |
+| STRING_CONTAINS | TEXT         | `s`: 待搜寻的字符串                  | BOOLEAN      | 判断字符串中是否存在`s`                   |
+| STRING_MATCHES  | TEXT         | `regex`: Java 标准库风格的正则表达式 | BOOLEAN      | 判断字符串是否能够被正则表达式`regex`匹配 |
+
+例如:
 
+```   sql
+select s1, string_contains(s1, "s"="warn"), string_matches(s1, "regex"="[^\\s]+37229") from root.sg1.d4;
 ```
-+-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
-|                         Time|root.ln.wf02.wt02.hardware|                         Time|root.ln.wf02.wt02.status|                         Time|root.ln.wf01.wt01.temperature|                         Time|root.ln.wf01.wt01.status|
-+-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
-|1970-01-01T08:00:00.001+08:00|                        v1|1970-01-01T08:00:00.001+08:00|                    true|2017-11-01T00:00:00.000+08:00|                        25.96|2017-11-01T00:00:00.000+08:00|                    true|
-|1970-01-01T08:00:00.002+08:00|                        v2|1970-01-01T08:00:00.002+08:00|                   false|2017-11-01T00:01:00.000+08:00|                        24.36|2017-11-01T00:01:00.000+08:00|                    true|
-|2017-11-01T00:00:00.000+08:00|                        v2|2017-11-01T00:00:00.000+08:00|                    true|                         null|                         null|                         null|                    null|
-|2017-11-01T00:01:00.000+08:00|                        v2|2017-11-01T00:01:00.000+08:00|                    true|                         null|                         null|                         null|                    null|
-+-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
-Total line number = 4
-It costs 0.018s
+
+结果:
+
+``` 
++-----------------------------+--------------+-------------------------------------------+------------------------------------------------------+
+|                         Time|root.sg1.d4.s1|string_contains(root.sg1.d4.s1, "s"="warn")|string_matches(root.sg1.d4.s1, "regex"="[^\\s]+37229")|
++-----------------------------+--------------+-------------------------------------------+------------------------------------------------------+
+|1970-01-01T08:00:00.001+08:00|    warn:-8721|                                       true|                                                 false|
+|1970-01-01T08:00:00.002+08:00|  error:-37229|                                      false|                                                  true|
+|1970-01-01T08:00:00.003+08:00|     warn:1731|                                       true|                                                 false|
++-----------------------------+--------------+-------------------------------------------+------------------------------------------------------+
+Total line number = 3
+It costs 0.007s
 ```
 
-更多语法请参照 [SQL REFERENCE](../Appendix/SQL-Reference.md)。
+#### 选择函数
 
-### 结果空值过滤
+目前 IoTDB 支持如下选择函数:
 
-* 如果结果集中,任意一列为 null,则过滤掉该行;即获得的结果集不包含任何空值
+| 函数名   | 输入序列类型                          | 必要的属性参数                                    | 输出序列类型             | 功能描述                                                     |
+| -------- | ------------------------------------- | ------------------------------------------------- | ------------------------ | ------------------------------------------------------------ |
+| TOP_K    | INT32 / INT64 / FLOAT / DOUBLE / TEXT | `k`: 最多选择的数据点数,必须大于 0 小于等于 1000 | 与输入序列的实际类型一致 | 返回某时间序列中值最大的`k`个数据点。若多于`k`个数据点的值并列最大,则返回时间戳最小的数据点。 |
+| BOTTOM_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT | `k`: 最多选择的数据点数,必须大于 0 小于等于 1000 | 与输入序列的实际类型一致 | 返回某时间序列中值最小的`k`个数据点。若多于`k`个数据点的值并列最小,则返回时间戳最小的数据点。 |
+
+例如:
 
+```   sql
+select s1, top_k(s1, "k"="2"), bottom_k(s1, "k"="2") from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00;
 ```
-select * from root.ln.* where time <= 2017-11-01T00:01:00 WITHOUT NULL ANY
+
+结果:
+
+``` 
++-----------------------------+--------------------+------------------------------+---------------------------------+
+|                         Time|      root.sg1.d2.s1|top_k(root.sg1.d2.s1, "k"="2")|bottom_k(root.sg1.d2.s1, "k"="2")|
++-----------------------------+--------------------+------------------------------+---------------------------------+
+|2020-12-10T20:36:15.531+08:00| 1531604122307244742|           1531604122307244742|                             null|
+|2020-12-10T20:36:15.532+08:00|-7426070874923281101|                          null|                             null|
+|2020-12-10T20:36:15.533+08:00|-7162825364312197604|          -7162825364312197604|                             null|
+|2020-12-10T20:36:15.534+08:00|-8581625725655917595|                          null|             -8581625725655917595|
+|2020-12-10T20:36:15.535+08:00|-7667364751255535391|                          null|             -7667364751255535391|
++-----------------------------+--------------------+------------------------------+---------------------------------+
+Total line number = 5
+It costs 0.006s
 ```
 
-* 在降采样查询中,如果结果集的某一行所有列都为 null,则过滤掉该行;即获得的结果集不包含所有值都为 null 的行
+#### 趋势计算函数
+
+目前 IoTDB 支持如下趋势计算函数:
+
+| 函数名                  | 输入序列类型                                    | 输出序列类型             | 功能描述                                                     |
+| ----------------------- | ----------------------------------------------- | ------------------------ | ------------------------------------------------------------ |
+| TIME_DIFFERENCE         | INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | INT64                    | 统计序列中某数据点的时间戳与前一数据点时间戳的差。范围内第一个数据点没有对应的结果输出。 |
+| DIFFERENCE              | INT32 / INT64 / FLOAT / DOUBLE                  | 与输入序列的实际类型一致 | 统计序列中某数据点的值与前一数据点的值的差。范围内第一个数据点没有对应的结果输出。 |
+| NON_NEGATIVE_DIFFERENCE | INT32 / INT64 / FLOAT / DOUBLE                  | 与输入序列的实际类型一致 | 统计序列中某数据点的值与前一数据点的值的差的绝对值。范围内第一个数据点没有对应的结果输出。 |
+| DERIVATIVE              | INT32 / INT64 / FLOAT / DOUBLE                  | DOUBLE                   | 统计序列中某数据点相对于前一数据点的变化率,数量上等同于 DIFFERENCE /  TIME_DIFFERENCE。范围内第一个数据点没有对应的结果输出。 |
+| NON_NEGATIVE_DERIVATIVE | INT32 / INT64 / FLOAT / DOUBLE                  | DOUBLE                   | 统计序列中某数据点相对于前一数据点的变化率的绝对值,数量上等同于 NON_NEGATIVE_DIFFERENCE /  TIME_DIFFERENCE。范围内第一个数据点没有对应的结果输出。 |
 
+例如:
+
+```   sql
+select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; 
 ```
-select * from root.ln.* where time <= 2017-11-01T00:01:00 WITHOUT NULL ALL
+
+结果:
+
+``` 
++-----------------------------+-------------------+-------------------------------+--------------------------+---------------------------------------+--------------------------+---------------------------------------+
+|                         Time|     root.sg1.d1.s1|time_difference(root.sg1.d1.s1)|difference(root.sg1.d1.s1)|non_negative_difference(root.sg1.d1.s1)|derivative(root.sg1.d1.s1)|non_negative_derivative(root.sg1.d1.s1)|
++-----------------------------+-------------------+-------------------------------+--------------------------+---------------------------------------+--------------------------+---------------------------------------+
+|2020-12-10T17:11:49.037+08:00|7360723084922759782|                              1|      -8431715764844238876|                    8431715764844238876|    -8.4317157648442388E18|                  8.4317157648442388E18|
+|2020-12-10T17:11:49.038+08:00|4377791063319964531|                              1|      -2982932021602795251|                    2982932021602795251|     -2.982932021602795E18|                   2.982932021602795E18|
+|2020-12-10T17:11:49.039+08:00|7972485567734642915|                              1|       3594694504414678384|                    3594694504414678384|     3.5946945044146785E18|                  3.5946945044146785E18|
+|2020-12-10T17:11:49.040+08:00|2508858212791964081|                              1|      -5463627354942678834|                    5463627354942678834|     -5.463627354942679E18|                   5.463627354942679E18|
+|2020-12-10T17:11:49.041+08:00|2817297431185141819|                              1|        308439218393177738|                     308439218393177738|     3.0843921839317773E17|                  3.0843921839317773E17|
++-----------------------------+-------------------+-------------------------------+--------------------------+---------------------------------------+--------------------------+---------------------------------------+
+Total line number = 5
+It costs 0.014s
 ```
 
+#### 自定义序列生成函数
+
+请参考 [UDF (用户定义函数)](../Advanced-Features/UDF-User-Defined-Function.md)。
+
 ### 聚合函数
 
 本章节主要介绍聚合查询的相关示例,
 主要使用的是 IoTDB SELECT 语句的聚合查询函数。
 
- * 统计总点数
+#### 统计总点数
 
-```
+```sql
 select count(status) from root.ln.wf01.wt01;
 ```
 结果:
@@ -324,40 +458,105 @@ Total line number = 1
 It costs 0.016s
 ```
 
-### 时间区间分组聚合
-
-本章节主要介绍时间区间分组聚合查询的相关示例,
-主要使用的是 IoTDB SELECT 语句的 [GROUP BY 子句](../Appendix/SQL-Reference.md),
-该子句是 IoTDB 中用于根据用户给定划分条件对结果集进行划分,并对已划分的结果集进行聚合计算的语句。
-IoTDB 支持根据时间间隔和自定义的滑动步长(默认值与时间间隔相同,自定义的值必须大于等于时间间隔)对结果集进行划分,默认结果按照时间升序排列。
-同时,您也可以使用 Java JDBC 标准接口来执行相关的查询语句。
-
-GROUP BY 语句为用户提供三类指定参数:
-
-* 参数 1:时间轴显示时间窗参数
-* 参数 2:划分时间轴的时间间隔参数(必须为正数)
-* 参数 3:滑动步长(可选参数,默认值与时间间隔相同,自定义的值必须大于等于时间间隔)
+#### 路径层级分组聚合
 
-三类参数的实际含义已经在下图中指出,这三类参数里,第三个参数是可选的。
-接下来,我们将给出三种典型的降频聚合查询的例子:
-滑动步长未指定,
-指定滑动步长,
-带值过滤条件。
+在时间序列层级结构中,分层聚合查询用于对某一层级进行聚合查询。
+这里使用 LEVEL 来统计指定层级下的聚合范围,该语句约定 root 为第 0 层序列,若统计"root.ln"下所有序列则需指定 level 为 1。
 
-<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto; margin-right:auto; display:block;" src="https://user-images.githubusercontent.com/16079446/69109512-f808bc80-0ab2-11ea-9e4d-b2b2f58fb474.png">
+例如:在"root.ln.wf01"下存在多个子序列:wt01,wt02,wt03 等均有名为 status 的序列,
+如果需要统计这些子序列的 status 包含的点个数,使用以下查询:
 
- * 未指定滑动步长的降频聚合查询
+```sql
+select count(status) from root.ln.wf01.* group by level=2
+```
 
-对应的 SQL 语句是:
+运行结果为:
 
 ```
-select count(status), max_value(temperature) from root.ln.wf01.wt01 group by ([2017-11-01T00:00:00, 2017-11-07T23:00:00),1d);
++----------------------------+
+|count(root.ln.wf01.*.status)|
++----------------------------+
+|                       10080|
++----------------------------+
+Total line number = 1
+It costs 0.003s
 ```
-这条查询的含义是:
 
-由于用户没有指定滑动步长,滑动步长将会被默认设置为跟时间间隔参数相同,也就是`1d`。
+假设此时添加两条序列,"root.ln.wf01.wt01.temperature" and "root.ln.wf02.wt01.temperature"。
+需要同时查询"root.ln.\*.\*.temperature"在第二层级的 count 聚合结果和 sum 聚合结果,可以使用下列查询语句:
 
-上面这个例子的第一个参数是显示窗口参数,决定了最终的显示范围是 [2017-11-01T00:00:00, 2017-11-07T23:00:00)。
+```sql
+select count(temperature), sum(temperature) from root.ln.*.* group by level=2
+```
+
+运行结果:
+
+```
++---------------------------------+---------------------------------+-------------------------------+-------------------------------+
+|count(root.ln.wf02.*.temperature)|count(root.ln.wf01.*.temperature)|sum(root.ln.wf02.*.temperature)|sum(root.ln.wf01.*.temperature)|
++---------------------------------+---------------------------------+-------------------------------+-------------------------------+
+|                                8|                                4|                          228.0|              91.83000183105469|
++---------------------------------+---------------------------------+-------------------------------+-------------------------------+
+Total line number = 1
+It costs 0.013s
+```
+
+若统计"root.ln.\*.\*"下第一层级的 count 聚合结果和 sum 聚合结果,则设置 level=1 即可:
+
+```sql
+select count(temperature), sum(temperature) from root.ln.*.* group by level=1
+```
+
+运行结果:
+
+```
++------------------------------+----------------------------+
+|count(root.ln.*.*.temperature)|sum(root.ln.*.*.temperature)|
++------------------------------+----------------------------+
+|                            12|           319.8300018310547|
++------------------------------+----------------------------+
+Total line number = 1
+It costs 0.013s
+```
+
+分层聚合查询也可被用于其他聚合函数,当前所支持的聚合函数为:count, sum, avg, last_value, first_value, min_time, max_time, min_value, max_value, extreme
+
+对于 sum, avg, min_value, max_value, extreme 五种聚合函数,需保证所有聚合的时间序列数据类型相同。其他聚合函数没有此限制。
+
+#### 时间区间分组聚合
+
+本章节主要介绍时间区间分组聚合查询的相关示例,
+主要使用的是 IoTDB SELECT 语句的 [GROUP BY 子句](../Appendix/SQL-Reference.md),
+该子句是 IoTDB 中用于根据用户给定划分条件对结果集进行划分,并对已划分的结果集进行聚合计算的语句。
+IoTDB 支持根据时间间隔和自定义的滑动步长(默认值与时间间隔相同,自定义的值必须大于等于时间间隔)对结果集进行划分,默认结果按照时间升序排列。
+同时,您也可以使用 Java JDBC 标准接口来执行相关的查询语句。
+
+GROUP BY 语句为用户提供三类指定参数:
+
+* 参数 1:时间轴显示时间窗参数
+* 参数 2:划分时间轴的时间间隔参数(必须为正数)
+* 参数 3:滑动步长(可选参数,默认值与时间间隔相同,自定义的值必须大于等于时间间隔)
+
+三类参数的实际含义已经在下图中指出,这三类参数里,第三个参数是可选的。
+接下来,我们将给出三种典型的降频聚合查询的例子:
+滑动步长未指定,
+指定滑动步长,
+带值过滤条件。
+
+<img style="width:100%; max-width:800px; max-height:600px; margin-left:auto; margin-right:auto; display:block;" src="https://user-images.githubusercontent.com/16079446/69109512-f808bc80-0ab2-11ea-9e4d-b2b2f58fb474.png">
+
+##### 未指定滑动步长的时间区间分组聚合查询
+
+对应的 SQL 语句是:
+
+```sql
+select count(status), max_value(temperature) from root.ln.wf01.wt01 group by ([2017-11-01T00:00:00, 2017-11-07T23:00:00),1d);
+```
+这条查询的含义是:
+
+由于用户没有指定滑动步长,滑动步长将会被默认设置为跟时间间隔参数相同,也就是`1d`。
+
+上面这个例子的第一个参数是显示窗口参数,决定了最终的显示范围是 [2017-11-01T00:00:00, 2017-11-07T23:00:00)。
 
 上面这个例子的第二个参数是划分时间轴的时间间隔参数,将`1d`当作划分间隔,显示窗口参数的起始时间当作分割原点,时间轴即被划分为连续的时间间隔:[0,1d), [1d, 2d), [2d, 3d) 等等。
 
@@ -381,11 +580,11 @@ Total line number = 7
 It costs 0.024s
 ```
 
- * 指定滑动步长的时间区间分组聚合查询
+##### 指定滑动步长的时间区间分组聚合查询
 
 对应的 SQL 语句是:
 
-```
+```sql
 select count(status), max_value(temperature) from root.ln.wf01.wt01 group by ([2017-11-01 00:00:00, 2017-11-07 23:00:00), 3h, 1d);
 ```
 
@@ -421,11 +620,11 @@ Total line number = 7
 It costs 0.006s
 ```
 
- * 按照自然月份的时间区间分组聚合查询
+##### 按照自然月份的时间区间分组聚合查询
 
 对应的 SQL 语句是:
 
-```
+```sql
 select count(status) from root.ln.wf01.wt01 where time > 2017-11-01T01:00:00 group by([2017-11-01T00:00:00, 2019-11-07T23:00:00), 1mo, 2mo);
 ```
 
@@ -469,7 +668,7 @@ select count(status) from root.ln.wf01.wt01 where time > 2017-11-01T01:00:00 gro
 
 对应的 SQL 语句是:
 
-```
+```sql
 select count(status) from root.ln.wf01.wt01 group by([2017-10-31T00:00:00, 2019-11-07T23:00:00), 1mo, 2mo);
 ```
 
@@ -511,11 +710,11 @@ select count(status) from root.ln.wf01.wt01 group by([2017-10-31T00:00:00, 2019-
 +-----------------------------+-------------------------------+
 ```
 
- * 左开右闭区间
+##### 左开右闭区间
 
 每个区间的结果时间戳为区间右端点,对应的 SQL 语句是:
 
-```
+```sql
 select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d);
 ```
 
@@ -539,66 +738,95 @@ Total line number = 7
 It costs 0.004s
 ```
 
-### 路径层级分组聚合
+#### 时间区间分组聚合查询补空值
 
-在时间序列层级结构中,分层聚合查询用于对某一层级进行聚合查询。
-这里使用 LEVEL 来统计指定层级下的聚合范围,该语句约定 root 为第 0 层序列,若统计"root.ln"下所有序列则需指定 level 为 1。
+时间区间分组聚合出的各个时间段的结果,支持使用前值补空。
 
-例如:在"root.ln.wf01"下存在多个子序列:wt01,wt02,wt03 等均有名为 status 的序列,
-如果需要统计这些子序列的 status 包含的点个数,使用以下查询:
-```
-select count(status) from root.ln.wf01.* group by level=2
-```
-运行结果为:
+不允许设置滑动步长,默认为聚合时间区间,实际为定长采样。现在只支持 last_value 聚合函数。
 
-```
-+----------------------------+
-|count(root.ln.wf01.*.status)|
-+----------------------------+
-|                       10080|
-+----------------------------+
-Total line number = 1
-It costs 0.003s
-```
+目前不支持线性插值补空值。
 
-假设此时添加两条序列,"root.ln.wf01.wt01.temperature" and "root.ln.wf02.wt01.temperature"。
-需要同时查询"root.ln.\*.\*.temperature"在第二层级的 count 聚合结果和 sum 聚合结果,可以使用下列查询语句:
-```
-select count(temperature), sum(temperature) from root.ln.*.* group by level=2
-```
-运行结果:
+PREVIOUS 和 PREVIOUSUNTILLAST 的区别
+
+* PREVIOUS:只要空值前边有值,就会用其填充空值。
+* PREVIOUSUNTILLAST:不会填充此序列最新点后的空值
+
+首先我们检查一下 root.ln.wf01.wt01.temperature 在时间 2017-11-07T23:50:00 以后的值
 
 ```
-+---------------------------------+---------------------------------+-------------------------------+-------------------------------+
-|count(root.ln.wf02.*.temperature)|count(root.ln.wf01.*.temperature)|sum(root.ln.wf02.*.temperature)|sum(root.ln.wf01.*.temperature)|
-+---------------------------------+---------------------------------+-------------------------------+-------------------------------+
-|                                8|                                4|                          228.0|              91.83000183105469|
-+---------------------------------+---------------------------------+-------------------------------+-------------------------------+
-Total line number = 1
-It costs 0.013s
+IoTDB> SELECT temperature FROM root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
++-----------------------------+-----------------------------+
+|                         Time|root.ln.wf01.wt01.temperature|
++-----------------------------+-----------------------------+
+|2017-11-07T23:50:00.000+08:00|                         23.7|
+|2017-11-07T23:51:00.000+08:00|                        22.24|
+|2017-11-07T23:52:00.000+08:00|                        20.18|
+|2017-11-07T23:53:00.000+08:00|                        24.58|
+|2017-11-07T23:54:00.000+08:00|                        22.52|
+|2017-11-07T23:55:00.000+08:00|                         25.9|
+|2017-11-07T23:56:00.000+08:00|                        24.44|
+|2017-11-07T23:57:00.000+08:00|                        24.39|
+|2017-11-07T23:58:00.000+08:00|                        22.93|
+|2017-11-07T23:59:00.000+08:00|                        21.07|
++-----------------------------+-----------------------------+
+Total line number = 10
+It costs 0.002s
 ```
 
-若统计"root.ln.\*.\*"下第一层级的 count 聚合结果和 sum 聚合结果,则设置 level=1 即可:
-```
-select count(temperature), sum(temperature) from root.ln.*.* group by level=1
+我们发现 root.ln.wf01.wt01.temperature 的最后时间和值是 2017-11-07T23:59:00 和 21.07。
+
+SQL 示例:
+
+```sql
+SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-08T00:01:00),1m) FILL (float[PREVIOUSUNTILLAST]);
+SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-08T00:01:00),1m) FILL (float[PREVIOUS]);
 ```
-运行结果:
+
+结果:
 
 ```
-+------------------------------+----------------------------+
-|count(root.ln.*.*.temperature)|sum(root.ln.*.*.temperature)|
-+------------------------------+----------------------------+
-|                            12|           319.8300018310547|
-+------------------------------+----------------------------+
-Total line number = 1
-It costs 0.013s
++-----------------------------+-----------------------------------------+
+|                         Time|last_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-----------------------------------------+
+|2017-11-07T23:50:00.000+08:00|                                     23.7|
+|2017-11-07T23:51:00.000+08:00|                                    22.24|
+|2017-11-07T23:52:00.000+08:00|                                    20.18|
+|2017-11-07T23:53:00.000+08:00|                                    24.58|
+|2017-11-07T23:54:00.000+08:00|                                    22.52|
+|2017-11-07T23:55:00.000+08:00|                                     25.9|
+|2017-11-07T23:56:00.000+08:00|                                    24.44|
+|2017-11-07T23:57:00.000+08:00|                                    24.39|
+|2017-11-07T23:58:00.000+08:00|                                    22.93|
+|2017-11-07T23:59:00.000+08:00|                                    21.07|
+|2017-11-08T00:00:00.000+08:00|                                     null|
++-----------------------------+-----------------------------------------+
+Total line number = 11
+It costs 0.005s
+
++-----------------------------+-----------------------------------------+
+|                         Time|last_value(root.ln.wf01.wt01.temperature)|
++-----------------------------+-----------------------------------------+
+|2017-11-07T23:50:00.000+08:00|                                     23.7|
+|2017-11-07T23:51:00.000+08:00|                                    22.24|
+|2017-11-07T23:52:00.000+08:00|                                    20.18|
+|2017-11-07T23:53:00.000+08:00|                                    24.58|
+|2017-11-07T23:54:00.000+08:00|                                    22.52|
+|2017-11-07T23:55:00.000+08:00|                                     25.9|
+|2017-11-07T23:56:00.000+08:00|                                    24.44|
+|2017-11-07T23:57:00.000+08:00|                                    24.39|
+|2017-11-07T23:58:00.000+08:00|                                    22.93|
+|2017-11-07T23:59:00.000+08:00|                                    21.07|
+|2017-11-08T00:00:00.000+08:00|                                    21.07|
++-----------------------------+-----------------------------------------+
+Total line number = 11
+It costs 0.006s
 ```
 
-分层聚合查询也可被用于其他聚合函数,当前所支持的聚合函数为:count, sum, avg, last_value, first_value, min_time, max_time, min_value, max_value, extreme
+解释:
 
-对于 sum, avg, min_value, max_value, extreme 五种聚合函数,需保证所有聚合的时间序列数据类型相同。其他聚合函数没有此限制。
+使用 PREVIOUSUNTILLAST 将不会填充 2017-11-07T23:59:00 以后的值。
 
-### 时间区间和路径层级分组聚合查询
+#### 时间区间和路径层级分组聚合查询
 
 除此之外,还可以通过定义 LEVEL 来统计指定层级下的数据点个数。
 
@@ -606,7 +834,7 @@ It costs 0.013s
 
 统计降采样后的数据点个数
 
-```
+```sql
 select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d), level=1;
 ```
 
@@ -630,7 +858,7 @@ It costs 0.006s
 
 加上滑动 Step 的降采样后的结果也可以汇总
 
-```
+```sql
 select count(status) from root.ln.wf01.wt01 group by ([0,20),2ms,3ms), level=1;
 ```
 
@@ -649,170 +877,44 @@ select count(status) from root.ln.wf01.wt01 group by ([0,20),2ms,3ms), level=1;
 Total line number = 7
 It costs 0.004s
 ```
-### 最新点查询
+### 空值填充
 
-SQL 语法:
+在 IoTDB 的实际使用中,当进行时间序列的查询操作时,可能会出现在某些时间点值为 null 的情况,这会妨碍用户进行进一步的分析。 为了更好地反映数据更改的程度,用户希望可以自动填充缺失值。 因此,IoTDB 系统引入了自动填充功能。
 
-```
-select last <Path> [COMMA <Path>]* from < PrefixPath > [COMMA < PrefixPath >]* <WhereClause>
-```
+自动填充功能是指对单列或多列执行时间序列查询时,根据用户指定的方法和有效时间范围填充空值。 如果查询点的值不为 null,则填充功能将不起作用。
 
-其含义是:查询时间序列 prefixPath.path 中最近时间戳的数据
+#### 填充方式
 
-\<WhereClause\>中当前只支持含有'>'或'>='的时间过滤条件,任何其他过滤条件都将会返回异常。
+- Previous 方式
 
-结果集为四列的结构
+当查询的时间戳值为空时,将使用前一个时间戳的值来填充空白。 形式化的先前方法如下(有关详细语法,请参见第 7.1.3.6 节):
 
-```
-+----+----------+-----+--------+
-|Time|timeseries|value|dataType|
-+----+----------+-----+--------+
+```sql
+select <path> from <prefixPath> where time = <T> fill(<data_type>[previous, <before_range>], …)
 ```
 
-示例 1:查询 root.ln.wf01.wt01.status 的最新数据点
+表 3-4 给出了所有参数的详细说明。
 
-```
-IoTDB> select last status from root.ln.wf01.wt01
-+-----------------------------+------------------------+-----+--------+
-|                         Time|              timeseries|value|dataType|
-+-----------------------------+------------------------+-----+--------+
-|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.status|false| BOOLEAN|
-+-----------------------------+------------------------+-----+--------+
-Total line number = 1
-It costs 0.000s
-```
+<center>**表 3-4previous 填充参数列表**
 
-示例 2:查询 root.ln.wf01.wt01 下 status,temperature 时间戳大于等于 2017-11-07T23:50:00 的最新数据点。
+| 参数名称(不区分大小写) | 解释                                                         |
+| :----------------------- | :----------------------------------------------------------- |
+| path, prefixPath         | 查询路径; 必填项                                            |
+| T                        | 查询时间戳(只能指定一个); 必填项                          |
+| data\_type               | 填充方法使用的数据类型。 可选值是 int32,int64,float,double,boolean,text; 可选字段 |
+| before\_range            | 表示前一种方法的有效时间范围。 当 [T-before \ _range,T] 范围内的值存在时,前一种方法将起作用。 如果未指定 before_range,则 before_range 会使用默认值 default_fill_interval; -1 表示无穷大; 可选字段 |
 
-```
-IoTDB> select last status, temperature from root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
-+-----------------------------+-----------------------------+---------+--------+
-|                         Time|                   timeseries|    value|dataType|
-+-----------------------------+-----------------------------+---------+--------+
-|2017-11-07T23:59:00.000+08:00|     root.ln.wf01.wt01.status|    false| BOOLEAN|
-|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.temperature|21.067368|  DOUBLE|
-+-----------------------------+-----------------------------+---------+--------+
-Total line number = 2
-It costs 0.002s
-```
+</center>
 
-### 模糊查询
+在这里,我们举一个使用先前方法填充空值的示例。 SQL 语句如下:
 
-模糊查询分为Like语句和Regexp语句,都可以支持对Text类型的数据进行模糊匹配
+```sql
+select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m]) 
+```
 
-Like语句:
+意思是:
 
-示例 1:查询 `root.sg.device` 下 `value` 含有`'cc'`的数据。
-`%` 表示任意0个或多个字符。
-
-```
-IoTDB> select * from root.sg.device where value like '%cc%'
-+-----------------------------+--------------------+
-|                         Time|root.sg.device.value|
-+-----------------------------+--------------------+
-|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
-|2017-11-07T23:59:00.000+08:00|                  cc|
-+-----------------------------+--------------------+
-Total line number = 2
-It costs 0.002s
-```
-
-示例 2:查询 `root.sg.device` 下 `value` 中间为 `'b'`、前后为任意单个字符的数据。
-`_` 表示任意单个字符。
-
-```
-IoTDB> select * from root.sg.device where value like '_b_'
-+-----------------------------+--------------------+
-|                         Time|root.sg.device.value|
-+-----------------------------+--------------------+
-|2017-11-07T23:59:00.000+08:00|                 abc| 
-+-----------------------------+--------------------+
-Total line number = 1
-It costs 0.002s
-```
-
-Regexp语句:
-
-需要传入的过滤条件为 Java 标准库风格的正则表达式
-
-示例 1:查询 root.sg.device 下 value 值为26个英文字符组成的字符串
-
-```
-IoTDB> select * from root.sg.device where value regexp '^[A-Za-z]+$'
-+-----------------------------+--------------------+
-|                         Time|root.sg.device.value|
-+-----------------------------+--------------------+
-|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
-|2017-11-07T23:59:00.000+08:00|                  cc|
-+-----------------------------+--------------------+
-Total line number = 2
-It costs 0.002s
-```
-
-示例 2:查询 root.sg.device 下 value 值为26个小写英文字符组成的字符串 且时间大于100的
-
-```
-IoTDB> select * from root.sg.device where value regexp '^[a-z]+$' and time > 100
-+-----------------------------+--------------------+
-|                         Time|root.sg.device.value|
-+-----------------------------+--------------------+
-|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
-|2017-11-07T23:59:00.000+08:00|                  cc|
-+-----------------------------+--------------------+
-Total line number = 2
-It costs 0.002s
-```
-
-常见的正则匹配举例:
-
-```
-长度为3-20的所有字符:^.{3,20}$
-大写英文字符:^[A-Z]+$
-数字和英文字符:^[A-Za-z0-9]+$
-以a开头的:^a.*
-```
-
-更多语法请参照 [SQL REFERENCE](../Appendix/SQL-Reference.md).
-### 空值填充
-
-在 IoTDB 的实际使用中,当进行时间序列的查询操作时,可能会出现在某些时间点值为 null 的情况,这会妨碍用户进行进一步的分析。 为了更好地反映数据更改的程度,用户希望可以自动填充缺失值。 因此,IoTDB 系统引入了自动填充功能。
-
-自动填充功能是指对单列或多列执行时间序列查询时,根据用户指定的方法和有效时间范围填充空值。 如果查询点的值不为 null,则填充功能将不起作用。
-
-> 注意:在当前版本中,IoTDB 为用户提供两种方法:Previous 和 Linear。 Previous 方法用前一个值填充空白。 Linear 方法通过线性拟合来填充空白。 并且填充功能只能在执行时间点查询时使用。
-
- * 填充功能
-
-- Previous 功能
-
-当查询的时间戳值为空时,将使用前一个时间戳的值来填充空白。 形式化的先前方法如下(有关详细语法,请参见第 7.1.3.6 节):
-
-```
-select <path> from <prefixPath> where time = <T> fill(<data_type>[previous, <before_range>], …)
-```
-
-表 3-4 给出了所有参数的详细说明。
-
-<center>**表 3-4previous 填充参数列表**
-
-| 参数名称(不区分大小写) | 解释                                                         |
-| :----------------------- | :----------------------------------------------------------- |
-| path, prefixPath         | 查询路径; 必填项                                            |
-| T                        | 查询时间戳(只能指定一个); 必填项                          |
-| data\_type               | 填充方法使用的数据类型。 可选值是 int32,int64,float,double,boolean,text; 可选字段 |
-| before\_range            | 表示前一种方法的有效时间范围。 当 [T-before \ _range,T] 范围内的值存在时,前一种方法将起作用。 如果未指定 before_range,则 before_range 会使用默认值 default_fill_interval; -1 表示无穷大; 可选字段 |
-
-</center>
-
-在这里,我们举一个使用先前方法填充空值的示例。 SQL 语句如下:
-
-```
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m]) 
-```
-
-意思是:
-
-由于时间根目录 root.sgcc.wf03.wt01.temperature 在 2017-11-01T16:37:50.000 为空,因此系统使用以前的时间戳 2017-11-01T16:37:00.000(且时间戳位于 [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] 范围)进行填充和显示。
+由于时间根目录 root.sgcc.wf03.wt01.temperature 在 2017-11-01T16:37:50.000 为空,因此系统使用以前的时间戳 2017-11-01T16:37:00.000(且时间戳位于 [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] 范围)进行填充和显示。
 
 在 [样例数据中](https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt), 该语句的执行结果如下所示:
 
@@ -843,7 +945,7 @@ It costs 0.004s
 
 当查询的时间戳值为空时,将使用前一个和下一个时间戳的值来填充空白。 形式化线性方法如下:
 
-```
+```sql
 select <path> from <prefixPath> where time = <T> fill(<data_type>[linear, <before_range>, <after_range>]…)
 ```
 
@@ -865,7 +967,7 @@ select <path> from <prefixPath> where time = <T> fill(<data_type>[linear, <befor
 
 在这里,我们举一个使用线性方法填充空值的示例。 SQL 语句如下:
 
-```
+```sql
 select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float [linear, 1m, 1m])
 ```
 
@@ -891,7 +993,7 @@ It costs 0.017s
 
 当查询的时间戳值为空时,将使用给定的值来填充空白。 特定值填充方法如下:
 
-```
+```sql
 select <path> from <prefixPath> where time = <T> fill(<data_type>[constant]…)
 ```
 
@@ -913,7 +1015,7 @@ select <path> from <prefixPath> where time = <T> fill(<data_type>[constant]…)
 
 在这里,我们举一个使用特定值方法填充空值的示例。 SQL语句如下:
 
-```
+```sql
 select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float [2.0])
 ```
 
@@ -933,7 +1035,7 @@ Total line number = 1
 It costs 0.007s
 ```
 
-数据类型和填充方法之间的对应关系
+#### 数据类型和填充方法之间的对应关系
 
 数据类型和支持的填充方法如表 3-6 所示。
 
@@ -952,123 +1054,176 @@ It costs 0.007s
 
 > 注意:应在 Fill 语句中至少指定一种填充方法。
 
- * 时间区间分组聚合查询补空值
-
-时间区间分组聚合出的各个时间段的结果,支持使用前值补空。
+### 最新点查询
 
-不允许设置滑动步长,默认为聚合时间区间,实际为定长采样。现在只支持 last_value 聚合函数。
+SQL 语法:
 
-目前不支持线性插值补空值。
+```sql
+select last <Path> [COMMA <Path>]* from < PrefixPath > [COMMA < PrefixPath >]* <WhereClause>
+```
 
-PREVIOUS 和 PREVIOUSUNTILLAST 的区别
+其含义是:查询时间序列 prefixPath.path 中最近时间戳的数据
 
-* PREVIOUS:只要空值前边有值,就会用其填充空值。
-* PREVIOUSUNTILLAST:不会填充此序列最新点后的空值
+\<WhereClause\>中当前只支持含有'>'或'>='的时间过滤条件,任何其他过滤条件都将会返回异常。
 
-首先我们检查一下 root.ln.wf01.wt01.temperature 在时间 2017-11-07T23:50:00 以后的值
+结果集为四列的结构
 
 ```
-IoTDB> SELECT temperature FROM root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
-+-----------------------------+-----------------------------+
-|                         Time|root.ln.wf01.wt01.temperature|
-+-----------------------------+-----------------------------+
-|2017-11-07T23:50:00.000+08:00|                         23.7|
-|2017-11-07T23:51:00.000+08:00|                        22.24|
-|2017-11-07T23:52:00.000+08:00|                        20.18|
-|2017-11-07T23:53:00.000+08:00|                        24.58|
-|2017-11-07T23:54:00.000+08:00|                        22.52|
-|2017-11-07T23:55:00.000+08:00|                         25.9|
-|2017-11-07T23:56:00.000+08:00|                        24.44|
-|2017-11-07T23:57:00.000+08:00|                        24.39|
-|2017-11-07T23:58:00.000+08:00|                        22.93|
-|2017-11-07T23:59:00.000+08:00|                        21.07|
-+-----------------------------+-----------------------------+
-Total line number = 10
-It costs 0.002s
++----+----------+-----+--------+
+|Time|timeseries|value|dataType|
++----+----------+-----+--------+
 ```
 
-我们发现 root.ln.wf01.wt01.temperature 的最后时间和值是 2017-11-07T23:59:00 和 21.07。
-
-SQL 示例:
+示例 1:查询 root.ln.wf01.wt01.status 的最新数据点
 
 ```
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-08T00:01:00),1m) FILL (float[PREVIOUSUNTILLAST]);
-SELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-08T00:01:00),1m) FILL (float[PREVIOUS]);
+IoTDB> select last status from root.ln.wf01.wt01
++-----------------------------+------------------------+-----+--------+
+|                         Time|              timeseries|value|dataType|
++-----------------------------+------------------------+-----+--------+
+|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.status|false| BOOLEAN|
++-----------------------------+------------------------+-----+--------+
+Total line number = 1
+It costs 0.000s
 ```
 
-结果:
+示例 2:查询 root.ln.wf01.wt01 下 status,temperature 时间戳大于等于 2017-11-07T23:50:00 的最新数据点。
 
 ```
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     23.7|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                    20.18|
-|2017-11-07T23:53:00.000+08:00|                                    24.58|
-|2017-11-07T23:54:00.000+08:00|                                    22.52|
-|2017-11-07T23:55:00.000+08:00|                                     25.9|
-|2017-11-07T23:56:00.000+08:00|                                    24.44|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                    22.93|
-|2017-11-07T23:59:00.000+08:00|                                    21.07|
-|2017-11-08T00:00:00.000+08:00|                                     null|
-+-----------------------------+-----------------------------------------+
-Total line number = 11
-It costs 0.005s
-
-+-----------------------------+-----------------------------------------+
-|                         Time|last_value(root.ln.wf01.wt01.temperature)|
-+-----------------------------+-----------------------------------------+
-|2017-11-07T23:50:00.000+08:00|                                     23.7|
-|2017-11-07T23:51:00.000+08:00|                                    22.24|
-|2017-11-07T23:52:00.000+08:00|                                    20.18|
-|2017-11-07T23:53:00.000+08:00|                                    24.58|
-|2017-11-07T23:54:00.000+08:00|                                    22.52|
-|2017-11-07T23:55:00.000+08:00|                                     25.9|
-|2017-11-07T23:56:00.000+08:00|                                    24.44|
-|2017-11-07T23:57:00.000+08:00|                                    24.39|
-|2017-11-07T23:58:00.000+08:00|                                    22.93|
-|2017-11-07T23:59:00.000+08:00|                                    21.07|
-|2017-11-08T00:00:00.000+08:00|                                    21.07|
-+-----------------------------+-----------------------------------------+
-Total line number = 11
-It costs 0.006s
+IoTDB> select last status, temperature from root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00
++-----------------------------+-----------------------------+---------+--------+
+|                         Time|                   timeseries|    value|dataType|
++-----------------------------+-----------------------------+---------+--------+
+|2017-11-07T23:59:00.000+08:00|     root.ln.wf01.wt01.status|    false| BOOLEAN|
+|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.temperature|21.067368|  DOUBLE|
++-----------------------------+-----------------------------+---------+--------+
+Total line number = 2
+It costs 0.002s
 ```
 
-解释:
-
-使用 PREVIOUSUNTILLAST 将不会填充 2017-11-07T23:59:00 以后的值。
-
-### LIMIT & OFFSET
-
-IoTDB 提供 [LIMIT/SLIMIT](../Appendix/SQL-Reference.md) 子句和 [OFFSET/SOFFSET](../Appendix/SQL-Reference.md) 子句,以使用户可以更好地控制查询结果。使用 LIMIT 和 SLIMIT 子句可让用户控制查询结果的行数和列数,
-并且使用 OFFSET 和 SOFSET 子句允许用户设置结果显示的起始位置。
-
-请注意,按组查询不支持 LIMIT 和 OFFSET。
+### 模糊查询
 
-本章主要介绍查询结果的行和列控制的相关示例。你还可以使用 [Java JDBC](../API/Programming-JDBC.md) 标准接口执行查询。
+模糊查询分为Like语句和Regexp语句,都可以支持对Text类型的数据进行模糊匹配
 
- * 查询结果的行控制
+Like语句:
 
-通过使用 LIMIT 和 OFFSET 子句,用户可以以与行相关的方式控制查询结果。 我们将通过以下示例演示如何使用 LIMIT 和 OFFSET 子句。
+示例 1:查询 `root.sg.device` 下 `value` 含有`'cc'`的数据。
+`%` 表示任意0个或多个字符。
 
-- 示例 1:基本的 LIMIT 子句
+```
+IoTDB> select * from root.sg.device where value like '%cc%'
++-----------------------------+--------------------+
+|                         Time|root.sg.device.value|
++-----------------------------+--------------------+
+|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
+|2017-11-07T23:59:00.000+08:00|                  cc|
++-----------------------------+--------------------+
+Total line number = 2
+It costs 0.002s
+```
 
-SQL 语句是:
+示例 2:查询 `root.sg.device` 下 `value` 中间为 `'b'`、前后为任意单个字符的数据。
+`_` 表示任意单个字符。
 
 ```
-select status, temperature from root.ln.wf01.wt01 limit 10
+IoTDB> select * from root.sg.device where value like '_b_'
++-----------------------------+--------------------+
+|                         Time|root.sg.device.value|
++-----------------------------+--------------------+
+|2017-11-07T23:59:00.000+08:00|                 abc| 
++-----------------------------+--------------------+
+Total line number = 1
+It costs 0.002s
 ```
 
-意思是:
+Regexp语句:
 
-所选设备为 ln 组 wf01 工厂 wt01 设备; 选择的时间序列是“状态”和“温度”。 SQL 语句要求返回查询结果的前 10 行。
+需要传入的过滤条件为 Java 标准库风格的正则表达式
 
-结果如下所示:
+示例 1:查询 root.sg.device 下 value 值为26个英文字符组成的字符串
 
 ```
-+-----------------------------+------------------------+-----------------------------+
+IoTDB> select * from root.sg.device where value regexp '^[A-Za-z]+$'
++-----------------------------+--------------------+
+|                         Time|root.sg.device.value|
++-----------------------------+--------------------+
+|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
+|2017-11-07T23:59:00.000+08:00|                  cc|
++-----------------------------+--------------------+
+Total line number = 2
+It costs 0.002s
+```
+
+示例 2:查询 root.sg.device 下 value 值为26个小写英文字符组成的字符串 且时间大于100的
+
+```
+IoTDB> select * from root.sg.device where value regexp '^[a-z]+$' and time > 100
++-----------------------------+--------------------+
+|                         Time|root.sg.device.value|
++-----------------------------+--------------------+
+|2017-11-07T23:59:00.000+08:00|            aabbccdd| 
+|2017-11-07T23:59:00.000+08:00|                  cc|
++-----------------------------+--------------------+
+Total line number = 2
+It costs 0.002s
+```
+
+常见的正则匹配举例:
+
+```
+长度为3-20的所有字符:^.{3,20}$
+大写英文字符:^[A-Z]+$
+数字和英文字符:^[A-Za-z0-9]+$
+以a开头的:^a.*
+```
+
+更多语法请参照 [SQL REFERENCE](../Appendix/SQL-Reference.md).
+
+### 别名
+
+由于 IoTDB 独特的数据模型,在每个传感器前都附带有设备等诸多额外信息。有时,我们只针对某个具体设备查询,而这些前缀信息频繁显示造成了冗余,影响了结果集的显示与分析。这时我们可以使用 IoTDB 提供的 AS 函数,将查询中出现的时间序列给定一个别名。
+
+例如:
+
+```sql
+select s1 as temperature, s2 as speed from root.ln.wf01.wt01;
+```
+
+则结果集将显示为:
+
+| Time | temperature | speed |
+| ---- | ----------- | ----- |
+| ...  | ...         | ...   |
+
+### 结果集行列输出控制 (LIMIT & OFFSET)
+
+IoTDB 提供 [LIMIT/SLIMIT](../Appendix/SQL-Reference.md) 子句和 [OFFSET/SOFFSET](../Appendix/SQL-Reference.md) 子句,以使用户可以更好地控制查询结果。使用 LIMIT 和 SLIMIT 子句可让用户控制查询结果的行数和列数,
+并且使用 OFFSET 和 SOFSET 子句允许用户设置结果显示的起始位置。
+
+请注意,按组查询不支持 LIMIT 和 OFFSET。
+
+本章主要介绍查询结果的行和列控制的相关示例。你还可以使用 [Java JDBC](../API/Programming-JDBC.md) 标准接口执行查询。
+
+#### 行控制
+
+通过使用 LIMIT 和 OFFSET 子句,用户可以以与行相关的方式控制查询结果。 我们将通过以下示例演示如何使用 LIMIT 和 OFFSET 子句。
+
+- 示例 1:基本的 LIMIT 子句
+
+SQL 语句是:
+
+```sql
+select status, temperature from root.ln.wf01.wt01 limit 10
+```
+
+意思是:
+
+所选设备为 ln 组 wf01 工厂 wt01 设备; 选择的时间序列是“状态”和“温度”。 SQL 语句要求返回查询结果的前 10 行。
+
+结果如下所示:
+
+```
++-----------------------------+------------------------+-----------------------------+
 |                         Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
 +-----------------------------+------------------------+-----------------------------+
 |2017-11-01T00:00:00.000+08:00|                    true|                        25.96|
@@ -1090,7 +1245,7 @@ It costs 0.000s
 
 SQL 语句是:
 
-```
+```sql
 select status, temperature from root.ln.wf01.wt01 limit 5 offset 3
 ```
 
@@ -1118,7 +1273,7 @@ It costs 0.342s
 
 SQL 语句是:
 
-```
+```sql
 select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time< 2017-11-01T00:12:00.000 limit 5 offset 3
 ```
 
@@ -1146,7 +1301,7 @@ It costs 0.000s
 
 SQL 语句是:
 
-```
+```sql
 select count(status), max_value(temperature) from root.ln.wf01.wt01 group by ([2017-11-01T00:00:00, 2017-11-07T23:00:00),1d) limit 4 offset 3
 ```
 
@@ -1171,7 +1326,7 @@ It costs 0.016s
 
 值得注意的是,由于当前的 FILL 子句只能在某个时间点填充时间序列的缺失值,也就是说,FILL 子句的执行结果恰好是一行,因此 LIMIT 和 OFFSET 不会是 与 FILL 子句结合使用,否则将提示错误。 例如,执行以下 SQL 语句:
 
-```
+```sql
 select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m]) limit 10
 ```
 
@@ -1181,7 +1336,7 @@ SQL 语句将不会执行,并且相应的错误提示如下:
 Msg: 401: Error occured while parsing SQL to physical plan: line 1:101 mismatched input 'limit' expecting {<EOF>, SLIMIT, SOFFSET, GROUP, DISABLE, ALIGN}
 ```
 
- * 查询结果的列控制
+#### 列控制
 
 通过使用 SLIMIT 和 SOFFSET 子句,用户可以与列相关的方式控制查询结果。 我们将通过以下示例演示如何使用 SLIMIT 和 SOFFSET 子句。
 
@@ -1189,7 +1344,7 @@ Msg: 401: Error occured while parsing SQL to physical plan: line 1:101 mismatche
 
 SQL 语句是:
 
-```
+```sql
 select * from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1
 ```
 
@@ -1218,7 +1373,7 @@ It costs 0.000s
 
 SQL 语句是:
 
-```
+```sql
 select * from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1 soffset 1
 ```
 
@@ -1247,9 +1402,8 @@ It costs 0.003s
 
 SQL 语句是:
 
-```
+```sql
 select max_value(*) from root.ln.wf01.wt01 group by ([2017-11-01T00:00:00, 2017-11-07T23:00:00),1d) slimit 1 soffset 1
-
 ```
 
 结果如下所示:
@@ -1274,9 +1428,8 @@ It costs 0.000s
 
 SQL 语句是:
 
-```
+```sql
 select * from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m]) slimit 1 soffset 1
-
 ```
 
 结果如下所示:
@@ -1291,15 +1444,14 @@ Total line number = 1
 It costs 0.007s
 ```
 
- * 控制查询结果的行和列
+#### 行和列控制的组合
 
 除了对查询结果进行行或列控制之外,IoTDB 还允许用户控制查询结果的行和列。 这是同时包含 LIMIT 子句和 SLIMIT 子句的完整示例。
 
 SQL 语句是:
 
-```
+```sql
 select * from root.ln.wf01.wt01 limit 10 offset 100 slimit 2 soffset 0
-
 ```
 
 意思是:
@@ -1327,226 +1479,12 @@ Total line number = 10
 It costs 0.009s
 ```
 
-### 别名
-
-由于 IoTDB 独特的数据模型,在每个传感器前都附带有设备等诸多额外信息。有时,我们只针对某个具体设备查询,而这些前缀信息频繁显示造成了冗余,影响了结果集的显示与分析。这时我们可以使用 IoTDB 提供的 AS 函数,将查询中出现的时间序列给定一个别名。
-
-例如:
-
-```
-select s1 as temperature, s2 as speed from root.ln.wf01.wt01;
-```
-
-则结果集将显示为:
-
-| Time | temperature | speed |
-| ---- | ----------- | ----- |
-| ...  | ...         | ...   |
-
-### 内置函数
-
-时间序列生成函数可接受若干原始时间序列作为输入,产生一列时间序列输出。与聚合函数不同的是,时间序列生成函数的结果集带有时间戳列。
-
-所有的时间序列生成函数都可以接受 * 作为输入,都可以与原始查询混合进行。
-
- * 数学函数
-
-目前 IoTDB 支持下列数学函数,这些数学函数的行为与这些函数在 Java Math 标准库中对应实现的行为一致。
-
-| 函数名  | 输入序列类型                   | 输出序列类型             | Java 标准库中的对应实现                                       |
-| ------- | ------------------------------ | ------------------------ | ------------------------------------------------------------ |
-| SIN     | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#sin(double)                                             |
-| COS     | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#cos(double)                                             |
-| TAN     | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#tan(double)                                             |
-| ASIN    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#asin(double)                                            |
-| ACOS    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#acos(double)                                            |
-| ATAN    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#atan(double)                                            |
-| SINH    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#sinh(double)                                            |
-| COSH    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#cosh(double)                                            |
-| TANH    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#tanh(double)                                            |
-| DEGREES | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#toDegrees(double)                                       |
-| RADIANS | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#toRadians(double)                                       |
-| ABS     | INT32 / INT64 / FLOAT / DOUBLE | 与输入序列的实际类型一致 | Math#abs(int) / Math#abs(long) /Math#abs(float) /Math#abs(double) |
-| SIGN    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#signum(double)                                          |
-| CEIL    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#ceil(double)                                            |
-| FLOOR   | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#floor(double)                                           |
-| ROUND   | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#rint(double)                                            |
-| EXP     | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#exp(double)                                             |
-| LN      | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#log(double)                                             |
-| LOG10   | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#log10(double)                                           |
-| SQRT    | INT32 / INT64 / FLOAT / DOUBLE | DOUBLE                   | Math#sqrt(double)                                            |
-
-例如:
-
-```   sql
-select s1, sin(s1), cos(s1), tan(s1) from root.sg1.d1 limit 5 offset 1000;
-```
-
-结果:
-
-```
-+-----------------------------+-------------------+-------------------+--------------------+-------------------+
-|                         Time|     root.sg1.d1.s1|sin(root.sg1.d1.s1)| cos(root.sg1.d1.s1)|tan(root.sg1.d1.s1)|
-+-----------------------------+-------------------+-------------------+--------------------+-------------------+
-|2020-12-10T17:11:49.037+08:00|7360723084922759782| 0.8133527237573284|  0.5817708713544664| 1.3980636773094157|
-|2020-12-10T17:11:49.038+08:00|4377791063319964531|-0.8938962705202537|  0.4482738644511651| -1.994085181866842|
-|2020-12-10T17:11:49.039+08:00|7972485567734642915| 0.9627757585308978|-0.27030138509681073|-3.5618602479083545|
-|2020-12-10T17:11:49.040+08:00|2508858212791964081|-0.6073417341629443| -0.7944406950452296| 0.7644897069734913|
-|2020-12-10T17:11:49.041+08:00|2817297431185141819|-0.8419358900502509| -0.5395775727782725| 1.5603611649667768|
-+-----------------------------+-------------------+-------------------+--------------------+-------------------+
-Total line number = 5
-It costs 0.008s
-```
-
- * 字符串函数
-
-目前 IoTDB 支持下列字符串处理函数:
-
-| 函数名          | 输入序列类型 | 必要的属性参数                      | 输出序列类型 | 功能描述                                  |
-| --------------- | ------------ | ----------------------------------- | ------------ | ----------------------------------------- |
-| STRING_CONTAINS | TEXT         | `s`: 待搜寻的字符串                 | BOOLEAN      | 判断字符串中是否存在`s`                   |
-| STRING_MATCHES  | TEXT         | `regex`: Java 标准库风格的正则表达式 | BOOLEAN      | 判断字符串是否能够被正则表达式`regex`匹配 |
-
-例如:
-
-```   sql
-select s1, string_contains(s1, "s"="warn"), string_matches(s1, "regex"="[^\\s]+37229") from root.sg1.d4;
-```
-
-结果:
-
-``` 
-+-----------------------------+--------------+-------------------------------------------+------------------------------------------------------+
-|                         Time|root.sg1.d4.s1|string_contains(root.sg1.d4.s1, "s"="warn")|string_matches(root.sg1.d4.s1, "regex"="[^\\s]+37229")|
-+-----------------------------+--------------+-------------------------------------------+------------------------------------------------------+
-|1970-01-01T08:00:00.001+08:00|    warn:-8721|                                       true|                                                 false|
-|1970-01-01T08:00:00.002+08:00|  error:-37229|                                      false|                                                  true|
-|1970-01-01T08:00:00.003+08:00|     warn:1731|                                       true|                                                 false|
-+-----------------------------+--------------+-------------------------------------------+------------------------------------------------------+
-Total line number = 3
-It costs 0.007s
-```
-
- * 选择函数
-
-目前 IoTDB 支持如下选择函数:
-
-| 函数名   | 输入序列类型                          | 必要的属性参数                                 | 输出序列类型             | 功能描述                                                     |
-| -------- | ------------------------------------- | ---------------------------------------------- | ------------------------ | ------------------------------------------------------------ |
-| TOP_K    | INT32 / INT64 / FLOAT / DOUBLE / TEXT | `k`: 最多选择的数据点数,必须大于 0 小于等于 1000 | 与输入序列的实际类型一致 | 返回某时间序列中值最大的`k`个数据点。若多于`k`个数据点的值并列最大,则返回时间戳最小的数据点。 |
-| BOTTOM_K | INT32 / INT64 / FLOAT / DOUBLE / TEXT | `k`: 最多选择的数据点数,必须大于 0 小于等于 1000 | 与输入序列的实际类型一致 | 返回某时间序列中值最小的`k`个数据点。若多于`k`个数据点的值并列最小,则返回时间戳最小的数据点。 |
-
-例如:
-
-```   sql
-select s1, top_k(s1, "k"="2"), bottom_k(s1, "k"="2") from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00;
-```
-
-结果:
-
-``` 
-+-----------------------------+--------------------+------------------------------+---------------------------------+
-|                         Time|      root.sg1.d2.s1|top_k(root.sg1.d2.s1, "k"="2")|bottom_k(root.sg1.d2.s1, "k"="2")|
-+-----------------------------+--------------------+------------------------------+---------------------------------+
-|2020-12-10T20:36:15.531+08:00| 1531604122307244742|           1531604122307244742|                             null|
-|2020-12-10T20:36:15.532+08:00|-7426070874923281101|                          null|                             null|
-|2020-12-10T20:36:15.533+08:00|-7162825364312197604|          -7162825364312197604|                             null|
-|2020-12-10T20:36:15.534+08:00|-8581625725655917595|                          null|             -8581625725655917595|
-|2020-12-10T20:36:15.535+08:00|-7667364751255535391|                          null|             -7667364751255535391|
-+-----------------------------+--------------------+------------------------------+---------------------------------+
-Total line number = 5
-It costs 0.006s
-```
-
- * 趋势计算函数
-
-目前 IoTDB 支持如下趋势计算函数:
-
-| 函数名                  | 输入序列类型                                    | 输出序列类型             | 功能描述                                                     |
-| ----------------------- | ----------------------------------------------- | ------------------------ | ------------------------------------------------------------ |
-| TIME_DIFFERENCE         | INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT | INT64                    | 统计序列中某数据点的时间戳与前一数据点时间戳的差。范围内第一个数据点没有对应的结果输出。 |
-| DIFFERENCE              | INT32 / INT64 / FLOAT / DOUBLE                  | 与输入序列的实际类型一致 | 统计序列中某数据点的值与前一数据点的值的差。范围内第一个数据点没有对应的结果输出。 |
-| NON_NEGATIVE_DIFFERENCE | INT32 / INT64 / FLOAT / DOUBLE                  | 与输入序列的实际类型一致 | 统计序列中某数据点的值与前一数据点的值的差的绝对值。范围内第一个数据点没有对应的结果输出。 |
-| DERIVATIVE              | INT32 / INT64 / FLOAT / DOUBLE                  | DOUBLE                   | 统计序列中某数据点相对于前一数据点的变化率,数量上等同于 DIFFERENCE /  TIME_DIFFERENCE。范围内第一个数据点没有对应的结果输出。 |
-| NON_NEGATIVE_DERIVATIVE | INT32 / INT64 / FLOAT / DOUBLE                  | DOUBLE                   | 统计序列中某数据点相对于前一数据点的变化率的绝对值,数量上等同于 NON_NEGATIVE_DIFFERENCE /  TIME_DIFFERENCE。范围内第一个数据点没有对应的结果输出。 |
-
-例如:
-
-```   sql
-select s1, time_difference(s1), difference(s1), non_negative_difference(s1), derivative(s1), non_negative_derivative(s1) from root.sg1.d1 limit 5 offset 1000; 
-```
-
-结果:
-
-``` 
-+-----------------------------+-------------------+-------------------------------+--------------------------+---------------------------------------+--------------------------+---------------------------------------+
-|                         Time|     root.sg1.d1.s1|time_difference(root.sg1.d1.s1)|difference(root.sg1.d1.s1)|non_negative_difference(root.sg1.d1.s1)|derivative(root.sg1.d1.s1)|non_negative_derivative(root.sg1.d1.s1)|
-+-----------------------------+-------------------+-------------------------------+--------------------------+---------------------------------------+--------------------------+---------------------------------------+
-|2020-12-10T17:11:49.037+08:00|7360723084922759782|                              1|      -8431715764844238876|                    8431715764844238876|    -8.4317157648442388E18|                  8.4317157648442388E18|
-|2020-12-10T17:11:49.038+08:00|4377791063319964531|                              1|      -2982932021602795251|                    2982932021602795251|     -2.982932021602795E18|                   2.982932021602795E18|
-|2020-12-10T17:11:49.039+08:00|7972485567734642915|                              1|       3594694504414678384|                    3594694504414678384|     3.5946945044146785E18|                  3.5946945044146785E18|
-|2020-12-10T17:11:49.040+08:00|2508858212791964081|                              1|      -5463627354942678834|                    5463627354942678834|     -5.463627354942679E18|                   5.463627354942679E18|
-|2020-12-10T17:11:49.041+08:00|2817297431185141819|                              1|        308439218393177738|                     308439218393177738|     3.0843921839317773E17|                  3.0843921839317773E17|
-+-----------------------------+-------------------+-------------------------------+--------------------------+---------------------------------------+--------------------------+---------------------------------------+
-Total line number = 5
-It costs 0.014s
-```
-
- * 自定义序列生成函数
-
-请参考 [UDF (用户定义函数)](../Advanced-Features/UDF-User-Defined-Function.md)。
-
-#### 算数运算查询
-
-##### 一元算数运算符
-
-支持的运算符:`+`, `-`
-
-输入数据类型要求:`INT32`, `INT64`, `FLOAT`和 `DOUBLE`
-
-输出数据类型:与输入数据类型一致
-
-##### 二元算数运算符
-
-支持的运算符:`+`, `-`, `*`, `/`,  `%`
-
-输入数据类型要求:`INT32`, `INT64`, `FLOAT`和 `DOUBLE`
-
-输出数据类型:`DOUBLE`
-
-注意:当某个时间戳下左操作数和右操作数都不为空(`null`)时,二元运算操作才会有输出结果
-
-##### 示例
-
-例如:
-
-```sql
-select s1, - s1, s2, + s2, s1 + s2, s1 - s2, s1 * s2, s1 / s2, s1 % s2 from root.sg.d1
-```
-
-结果:
-
-``` 
-+-----------------------------+-------------+--------------+-------------+-------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+
-|                         Time|root.sg.d1.s1|-root.sg.d1.s1|root.sg.d1.s2|root.sg.d1.s2|root.sg.d1.s1 + root.sg.d1.s2|root.sg.d1.s1 - root.sg.d1.s2|root.sg.d1.s1 * root.sg.d1.s2|root.sg.d1.s1 / root.sg.d1.s2|root.sg.d1.s1 % root.sg.d1.s2|
-+-----------------------------+-------------+--------------+-------------+-------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+
-|1970-01-01T08:00:00.001+08:00|          1.0|          -1.0|          1.0|          1.0|                          2.0|                          0.0|                          1.0|                          1.0|                          0.0|
-|1970-01-01T08:00:00.002+08:00|          2.0|          -2.0|          2.0|          2.0|                          4.0|                          0.0|                          4.0|                          1.0|                          0.0|
-|1970-01-01T08:00:00.003+08:00|          3.0|          -3.0|          3.0|          3.0|                          6.0|                          0.0|                          9.0|                          1.0|                          0.0|
-|1970-01-01T08:00:00.004+08:00|          4.0|          -4.0|          4.0|          4.0|                          8.0|                          0.0|                         16.0|                          1.0|                          0.0|
-|1970-01-01T08:00:00.005+08:00|          5.0|          -5.0|          5.0|          5.0|                         10.0|                          0.0|                         25.0|                          1.0|                          0.0|
-+-----------------------------+-------------+--------------+-------------+-------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+-----------------------------+
-Total line number = 5
-It costs 0.014s
-```
-
 #### 错误处理
 
 当 LIMIT / SLIMIT 的参数 N / SN 超过结果集的大小时,IoTDB 将按预期返回所有结果。 例如,原始 SQL 语句的查询结果由六行组成,我们通过 LIMIT 子句选择前 100 行:
 
-```
+```sql
 select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 limit 100
-
 ```
 
 结果如下所示:
@@ -1568,9 +1506,8 @@ It costs 0.005s
 
 当 LIMIT / SLIMIT 子句的参数 N / SN 超过允许的最大值(N / SN 的类型为 int32)时,系统将提示错误。 例如,执行以下 SQL 语句:
 
-```
+```sql
 select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 limit 1234567890123456789
-
 ```
 
 SQL 语句将不会执行,并且相应的错误提示如下:
@@ -1581,9 +1518,8 @@ Msg: 303: check metadata error: Out of range. LIMIT <N>: N should be Int32.
 
 当 LIMIT / LIMIT 子句的参数 N / SN 不是正整数时,系统将提示错误。 例如,执行以下 SQL 语句:
 
-```
+```sql
 select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 limit 13.1
-
 ```
 
 SQL 语句将不会执行,并且相应的错误提示如下:
@@ -1594,9 +1530,8 @@ Msg: 401: line 1:129 mismatched input '.' expecting {<EOF>, SLIMIT, OFFSET, SOFF
 
 当 LIMIT 子句的参数 OFFSET 超过结果集的大小时,IoTDB 将返回空结果集。 例如,执行以下 SQL 语句:
 
-```
+```sql
 select status,temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 limit 2 offset 6
-
 ```
 
 结果如下所示:
@@ -1609,6 +1544,76 @@ Empty set.
 It costs 0.005s
 ```
 
+### 结果集空值过滤
+
+* 如果结果集中,任意一列为 null,则过滤掉该行;即获得的结果集不包含任何空值
+
+```sql
+select * from root.ln.* where time <= 2017-11-01T00:01:00 WITHOUT NULL ANY
+```
+
+* 在降采样查询中,如果结果集的某一行所有列都为 null,则过滤掉该行;即获得的结果集不包含所有值都为 null 的行
+
+```sql
+select * from root.ln.* where time <= 2017-11-01T00:01:00 WITHOUT NULL ALL
+```
+
+### 其他对齐方式的结果集
+
+IoTDB 支持另外两种结果返回形式:按设备时间对齐 'align by device' 和 时序不对齐 'disable align'.
+
+#### align by device
+
+'align by device' 对齐方式下,设备 ID 会单独作为一列出现。在 select 子句中写了多少列,最终结果就会有该列数+2 (时间列和设备名字列)。SQL 形如:
+
+```sql
+select * from root.ln.* where time <= 2017-11-01T00:01:00 align by device
+```
+
+结果如下:
+
+```
++-----------------------------+-----------------+-----------+------+--------+
+|                         Time|           Device|temperature|status|hardware|
++-----------------------------+-----------------+-----------+------+--------+
+|2017-11-01T00:00:00.000+08:00|root.ln.wf01.wt01|      25.96|  true|    null|
+|2017-11-01T00:01:00.000+08:00|root.ln.wf01.wt01|      24.36|  true|    null|
+|1970-01-01T08:00:00.001+08:00|root.ln.wf02.wt02|       null|  true|      v1|
+|1970-01-01T08:00:00.002+08:00|root.ln.wf02.wt02|       null| false|      v2|
+|2017-11-01T00:00:00.000+08:00|root.ln.wf02.wt02|       null|  true|      v2|
+|2017-11-01T00:01:00.000+08:00|root.ln.wf02.wt02|       null|  true|      v2|
++-----------------------------+-----------------+-----------+------+--------+
+Total line number = 6
+It costs 0.012s
+```
+
+#### disable align
+
+'disable align' 意味着每条时序就有 2 列存在。Disable Align 只能用于查询语句句尾,不能用于聚合查询、Fill 语句、Group by 或 Group by device 语句,但可用于 Limit 语句。结果显示若无数据显示为空白。
+
+SQL 形如:
+
+```sql
+select * from root.ln.* where time <= 2017-11-01T00:01:00 disable align
+```
+
+结果如下:
+
+```
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+|                         Time|root.ln.wf02.wt02.hardware|                         Time|root.ln.wf02.wt02.status|                         Time|root.ln.wf01.wt01.temperature|                         Time|root.ln.wf01.wt01.status|
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+|1970-01-01T08:00:00.001+08:00|                        v1|1970-01-01T08:00:00.001+08:00|                    true|2017-11-01T00:00:00.000+08:00|                        25.96|2017-11-01T00:00:00.000+08:00|                    true|
+|1970-01-01T08:00:00.002+08:00|                        v2|1970-01-01T08:00:00.002+08:00|                   false|2017-11-01T00:01:00.000+08:00|                        24.36|2017-11-01T00:01:00.000+08:00|                    true|
+|2017-11-01T00:00:00.000+08:00|                        v2|2017-11-01T00:00:00.000+08:00|                    true|                         null|                         null|                         null|                    null|
+|2017-11-01T00:01:00.000+08:00|                        v2|2017-11-01T00:01:00.000+08:00|                    true|                         null|                         null|                         null|                    null|
++-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+
+Total line number = 4
+It costs 0.018s
+```
+
+更多语法请参照 [SQL REFERENCE](../Appendix/SQL-Reference.md)。
+
 ## 数据删除
 
 用户使用 [DELETE 语句](../Appendix/SQL-Reference.md) 可以删除指定的时间序列中符合时间删除条件的数据。在删除数据时,用户可以选择需要删除的一个或多个时间序列、时间序列的前缀、时间序列带、*路径对某一个时间区间内的数据进行删除。
@@ -1621,17 +1626,17 @@ It costs 0.005s
 
 wf02 子站的 wt02 设备在 2017-11-01 16:26:00 之前的供电状态出现多段错误,且无法分析其正确数据,错误数据影响了与其他设备的关联分析。此时,需要将此时间段前的数据删除。进行此操作的 SQL 语句为:
 
-```
+```sql
 delete from root.ln.wf02.wt02.status where time<=2017-11-01T16:26:00;
 ```
 
 如果我们仅仅想要删除 2017 年内的在 2017-11-01 16:26:00 之前的数据,可以使用以下 SQL:
-```
+```sql
 delete from root.ln.wf02.wt02.status where time>=2017-01-01T00:00:00 and time<=2017-11-01T16:26:00;
 ```
 
 IoTDB 支持删除一个时间序列任何一个时间范围内的所有时序点,用户可以使用以下 SQL 语句指定需要删除的时间范围:
-```
+```sql
 delete from root.ln.wf02.wt02.status where time < 10
 delete from root.ln.wf02.wt02.status where time <= 10
 delete from root.ln.wf02.wt02.status where time < 20 and time > 10
@@ -1649,7 +1654,7 @@ expressions like : time > XXX, time <= XXX, or two atomic expressions connected
 ```
 
 如果 delete 语句中未指定 where 子句,则会删除时间序列中的所有数据。
-```
+```sql
 delete from root.ln.wf02.status
 ```
 
@@ -1657,19 +1662,19 @@ delete from root.ln.wf02.status
 
 当 ln 集团 wf02 子站的 wt02 设备在 2017-11-01 16:26:00 之前的供电状态和设备硬件版本都需要删除,此时可以使用含义更广的 [前缀路径或带`*`路径](../Data-Concept/Data-Model-and-Terminology.md) 进行删除操作,进行此操作的 SQL 语句为:
 
-```
+```sql
 delete from root.ln.wf02.wt02 where time <= 2017-11-01T16:26:00;
 ```
 
 或
 
-```
+```sql
 delete from root.ln.wf02.wt02.* where time <= 2017-11-01T16:26:00;
 ```
 
 需要注意的是,当删除的路径不存在时,IoTDB 不会提示路径不存在,而是显示执行成功,因为 SQL 是一种声明式的编程方式,除非是语法错误、权限不足等,否则都不认为是错误,如下所示。
 
-```
+```sql
 IoTDB> delete from root.ln.wf03.wt02.status where time < now()
 Msg: The statement is executed successfully.
 ```
@@ -1677,7 +1682,7 @@ Msg: The statement is executed successfully.
 ### 删除时间分区 (实验性功能)
 您可以通过如下语句来删除某一个存储组下的指定时间分区:
 
-```
+```sql
 DELETE PARTITION root.ln 0,1,2
 ```
 
@@ -1685,3 +1690,4 @@ DELETE PARTITION root.ln 0,1,2
 手动地将一个时间戳转换为对应的 id,其中的`partitionInterval`可以在 IoTDB 的配置文件中找到(如果您使用的版本支持时间分区)。
 
 请注意该功能目前只是实验性的,如果您不是开发者,使用时请务必谨慎。
+