diff --git a/docs/UserGuide/5-Operation Manual/2-DML Data Manipulation Language.md b/docs/UserGuide/5-Operation Manual/2-DML Data Manipulation Language.md index 50ea02d0b6c3d..5f153540bf47a 100644 --- a/docs/UserGuide/5-Operation Manual/2-DML Data Manipulation Language.md +++ b/docs/UserGuide/5-Operation Manual/2-DML Data Manipulation Language.md @@ -244,36 +244,44 @@ The path after SELECT in GROUP BY statement must be aggregate function, otherwis
-### Last timestamp Query -In scenarios when IoT devices updates data in a fast manner, users are more interested in the most recent record of IoT devices. -The LAST query is to return the most recent value of the given timeseries in a time-value pair format. +### Last point Query -The SQL statement is: +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: ``` select last [COMMA ]* from < PrefixPath > [COMMA < PrefixPath >]* ``` -which means: -Query and return the data with the largest timestamp of timeseries prefixPath.path. +which means: Query and return the last data points of timeseries prefixPath.path. + +The result will be returned in a three column table format. -In the following example, we queries the latest record of timeseries root.ln.wf01.wt01.status: ``` -select last status from root.ln.wf01.wt01 disable align +| Time | Path | Value | ``` -The result will be returned in a three column table format. + +Example 1: get the last point of root.ln.wf01.wt01.speed: + ``` +> select last speed from root.ln.wf01.wt01 + | Time | Path | Value | | --- | ----------------------- | ----- | -| 5 | root.ln.wf01.wt01.status| 100 | +| 5 | root.ln.wf01.wt01.speed | 100 | ``` -If the path root.ln.wf01.wt01 has multiple columns, for example id, status and temperature, the following case will return records of all the three measurements with the largest timestamp. + +Example 2: get the last speed, status and temperature points of root.ln.wf01.wt01 + ``` -select last id, status, temperature from root.ln.wf01.wt01 disable align +> select last speed, status, temperature from root.ln.wf01.wt01 | Time | Path | Value | | --- | ---------------------------- | ----- | -| 5 | root.ln.wf01.wt01.id | 10 | +| 5 | root.ln.wf01.wt01.speed | 100 | | 7 | root.ln.wf01.wt01.status | true | | 9 | root.ln.wf01.wt01.temperature| 35.7 | ``` diff --git a/docs/zh/UserGuide/5-Operation Manual/2-DML Data Manipulation Language.md b/docs/zh/UserGuide/5-Operation Manual/2-DML Data Manipulation Language.md index dc4e97e7a8e14..d359ebd1e1fc4 100644 --- a/docs/zh/UserGuide/5-Operation Manual/2-DML Data Manipulation Language.md +++ b/docs/zh/UserGuide/5-Operation Manual/2-DML Data Manipulation Language.md @@ -273,35 +273,40 @@ GROUP BY的SELECT子句里的查询路径必须是聚合函数,否则系统将
-### 最近时间戳数据查询 +### 最新数据查询 -对应的SQL语句是: +SQL语法: ``` select last [COMMA ]* from < PrefixPath > [COMMA < PrefixPath >]* ``` -其含义是: -查询时间序列prefixPath.path中最近时间戳的数据 +其含义是:查询时间序列prefixPath.path中最近时间戳的数据 + +结果集为三列的结构 -下面的例子中查询时间序列root.ln.wf01.wt01.status最近时间戳的数据: ``` -select last status from root.ln.wf01.wt01 disable align +| Time | Path | Value | ``` -结果集为以下的形式返回: + +示例 1:查询 root.ln.wf01.wt01.speed 的最新数据点 + ``` +> select last speed from root.ln.wf01.wt01 + | Time | Path | Value | | --- | ----------------------- | ----- | -| 5 | root.ln.wf01.wt01.status| 100 | +| 5 | root.ln.wf01.wt01.speed | 100 | ``` -假设root.ln.wf01.wt01中包含多列数据,如id, status, temperature,下面的例子将会把这几列数据在最近时间戳的记录同时返回: +示例 2:查询 root.ln.wf01.wt01 下 speed,status,temperature 的最新数据点 + ``` -select last id, status, temperature from root.ln.wf01 disable align +> select last speed, status, temperature from root.ln.wf01 | Time | Path | Value | | --- | ---------------------------- | ----- | -| 5 | root.ln.wf01.wt01.id | 10 | +| 5 | root.ln.wf01.wt01.speed | 100 | | 7 | root.ln.wf01.wt01.status | true | | 9 | root.ln.wf01.wt01.temperature| 35.7 | ```