blob: 0822249df20c766dcdf93a09d22a3471052d7e4b [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[85],{653:function(e,t,s){"use strict";s.r(t);var a=s(69),n=Object(a.a)({},(function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[s("h1",{attrs:{id:"dml-data-manipulation-language"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#dml-data-manipulation-language"}},[e._v("#")]),e._v(" DML (Data Manipulation Language)")]),e._v(" "),s("h2",{attrs:{id:"insert"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#insert"}},[e._v("#")]),e._v(" INSERT")]),e._v(" "),s("h3",{attrs:{id:"insert-real-time-data"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#insert-real-time-data"}},[e._v("#")]),e._v(" Insert Real-time Data")]),e._v(" "),s("p",[e._v("IoTDB provides users with a variety of ways to insert real-time data, such as directly inputting "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("INSERT SQL statement")]),e._v(" in "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Client/Command Line Interface.html"}},[e._v("Client/Shell tools")]),e._v(", or using "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Client/Programming - JDBC.html"}},[e._v("Java JDBC")]),e._v(" to perform single or batch execution of "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("INSERT SQL statement")]),e._v(".")],1),e._v(" "),s("p",[e._v("This section mainly introduces the use of "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("INSERT SQL statement")]),e._v(" for real-time data import in the scenario.")],1),e._v(" "),s("h4",{attrs:{id:"use-of-insert-statements"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#use-of-insert-statements"}},[e._v("#")]),e._v(" Use of INSERT Statements")]),e._v(" "),s("p",[e._v("The "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("INSERT SQL statement")]),e._v(" statement is used to insert data into one or more specified timeseries created. For each point of data inserted, it consists of a "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Concept/Data Model and Terminology.html"}},[e._v("timestamp")]),e._v(" and a sensor acquisition value (see "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Concept/Data Type.html"}},[e._v("Data Type")]),e._v(").")],1),e._v(" "),s("p",[e._v("In the scenario of this section, take two timeseries "),s("code",[e._v("root.ln.wf02.wt02.status")]),e._v(" and "),s("code",[e._v("root.ln.wf02.wt02.hardware")]),e._v(" as an example, and their data types are BOOLEAN and TEXT, respectively.")]),e._v(" "),s("p",[e._v("The sample code for single column data insertion is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v('IoTDB > insert into root.ln.wf02.wt02(timestamp,status) values(1,true)\nIoTDB > insert into root.ln.wf02.wt02(timestamp,hardware) values(1, "v1")\n')])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br")])]),s("p",[e._v('The above example code inserts the long integer timestamp and the value "true" into the timeseries '),s("code",[e._v("root.ln.wf02.wt02.status")]),e._v(' and inserts the long integer timestamp and the value "v1" into the timeseries '),s("code",[e._v("root.ln.wf02.wt02.hardware")]),e._v(". When the execution is successful, cost time is shown to indicate that the data insertion has been completed.")]),e._v(" "),s("blockquote",[s("p",[e._v("Note: In IoTDB, TEXT type data can be represented by single and double quotation marks. The insertion statement above uses double quotation marks for TEXT type data. The following example will use single quotation marks for TEXT type data.")])]),e._v(" "),s("p",[e._v("The INSERT statement can also support the insertion of multi-column data at the same time point. The sample code of inserting the values of the two timeseries at the same time point '2' is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB > insert into root.ln.wf02.wt02(timestamp, status, hardware) VALUES (2, false, 'v2')\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("After inserting the data, we can simply query the inserted data using the SELECT statement:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB > select * from root.ln.wf02 where time < 3\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The result is shown below. The query result shows that the insertion statements of single column and multi column data are performed correctly.")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+--------------------------+------------------------+\n| Time|root.ln.wf02.wt02.hardware|root.ln.wf02.wt02.status|\n+-----------------------------+--------------------------+------------------------+\n|1970-01-01T08:00:00.001+08:00| v1| true|\n|1970-01-01T08:00:00.002+08:00| v2| false|\n+-----------------------------+--------------------------+------------------------+\nTotal line number = 2\nIt costs 0.170s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br")])]),s("h2",{attrs:{id:"select"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#select"}},[e._v("#")]),e._v(" SELECT")]),e._v(" "),s("h3",{attrs:{id:"time-slice-query"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#time-slice-query"}},[e._v("#")]),e._v(" Time Slice Query")]),e._v(" "),s("p",[e._v("This chapter mainly introduces the relevant examples of time slice query using IoTDB SELECT statements. Detailed SQL syntax and usage specifications can be found in "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("SQL Documentation")]),e._v(". You can also use the "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Client/Programming - JDBC.html"}},[e._v("Java JDBC")]),e._v(" standard interface to execute related queries.")],1),e._v(" "),s("h4",{attrs:{id:"select-a-column-of-data-based-on-a-time-interval"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#select-a-column-of-data-based-on-a-time-interval"}},[e._v("#")]),e._v(" Select a Column of Data Based on a Time Interval")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select temperature from root.ln.wf01.wt01 where time < 2017-11-01T00:08:00.000\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is the temperature sensor (temperature). The SQL statement requires that all temperature sensor values before the time point of "2017-11-01T00:08:00.000" be selected.')]),e._v(" "),s("p",[e._v("The execution result of this SQL statement is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-----------------------------+\n| Time|root.ln.wf01.wt01.temperature|\n+-----------------------------+-----------------------------+\n|2017-11-01T00:00:00.000+08:00| 25.96|\n|2017-11-01T00:01:00.000+08:00| 24.36|\n|2017-11-01T00:02:00.000+08:00| 20.09|\n|2017-11-01T00:03:00.000+08:00| 20.18|\n|2017-11-01T00:04:00.000+08:00| 21.13|\n|2017-11-01T00:05:00.000+08:00| 22.72|\n|2017-11-01T00:06:00.000+08:00| 20.71|\n|2017-11-01T00:07:00.000+08:00| 21.45|\n+-----------------------------+-----------------------------+\nTotal line number = 8\nIt costs 0.026s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br")])]),s("h4",{attrs:{id:"select-multiple-columns-of-data-based-on-a-time-interval"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#select-multiple-columns-of-data-based-on-a-time-interval"}},[e._v("#")]),e._v(" Select Multiple Columns of Data Based on a Time Interval")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select status, temperature from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000;\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature". The SQL statement requires that the status and temperature sensor values between the time point of "2017-11-01T00:05:00.000" and "2017-11-01T00:12:00.000" be selected.')]),e._v(" "),s("p",[e._v("The execution result of this SQL statement is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+------------------------+-----------------------------+\n| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|\n+-----------------------------+------------------------+-----------------------------+\n|2017-11-01T00:06:00.000+08:00| false| 20.71|\n|2017-11-01T00:07:00.000+08:00| false| 21.45|\n|2017-11-01T00:08:00.000+08:00| false| 22.58|\n|2017-11-01T00:09:00.000+08:00| false| 20.98|\n|2017-11-01T00:10:00.000+08:00| true| 25.52|\n|2017-11-01T00:11:00.000+08:00| false| 22.91|\n+-----------------------------+------------------------+-----------------------------+\nTotal line number = 6\nIt costs 0.018s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br")])]),s("h4",{attrs:{id:"select-multiple-columns-of-data-for-the-same-device-according-to-multiple-time-intervals"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#select-multiple-columns-of-data-for-the-same-device-according-to-multiple-time-intervals"}},[e._v("#")]),e._v(" Select Multiple Columns of Data for the Same Device According to Multiple Time Intervals")]),e._v(" "),s("p",[e._v("IoTDB supports specifying multiple time interval conditions in a query. Users can combine time interval conditions at will according to their needs. For example, the SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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);\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature"; the statement specifies two different time intervals, namely "2017-11-01T00:05:00.000 to 2017-11-01T00:12:00.000" and "2017-11-01T16:35:00.000 to 2017-11-01T16:37:00.000". The SQL statement requires that the values of selected timeseries satisfying any time interval be selected.')]),e._v(" "),s("p",[e._v("The execution result of this SQL statement is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+------------------------+-----------------------------+\n| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|\n+-----------------------------+------------------------+-----------------------------+\n|2017-11-01T00:06:00.000+08:00| false| 20.71|\n|2017-11-01T00:07:00.000+08:00| false| 21.45|\n|2017-11-01T00:08:00.000+08:00| false| 22.58|\n|2017-11-01T00:09:00.000+08:00| false| 20.98|\n|2017-11-01T00:10:00.000+08:00| true| 25.52|\n|2017-11-01T00:11:00.000+08:00| false| 22.91|\n|2017-11-01T16:35:00.000+08:00| true| 23.44|\n|2017-11-01T16:36:00.000+08:00| false| 21.98|\n|2017-11-01T16:37:00.000+08:00| false| 21.93|\n+-----------------------------+------------------------+-----------------------------+\nTotal line number = 9\nIt costs 0.018s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br")])]),s("h4",{attrs:{id:"choose-multiple-columns-of-data-for-different-devices-according-to-multiple-time-intervals"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#choose-multiple-columns-of-data-for-different-devices-according-to-multiple-time-intervals"}},[e._v("#")]),e._v(" Choose Multiple Columns of Data for Different Devices According to Multiple Time Intervals")]),e._v(" "),s("p",[e._v("The system supports the selection of data in any column in a query, i.e., the selected columns can come from different devices. For example, the SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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);\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v('The selected timeseries are "the power supply status of ln group wf01 plant wt01 device" and "the hardware version of ln group wf02 plant wt02 device"; the statement specifies two different time intervals, namely "2017-11-01T00:05:00.000 to 2017-11-01T00:12:00.000" and "2017-11-01T16:35:00.000 to 2017-11-01T16:37:00.000". The SQL statement requires that the values of selected timeseries satisfying any time interval be selected.')]),e._v(" "),s("p",[e._v("The execution result of this SQL statement is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+------------------------+--------------------------+\n| Time|root.ln.wf01.wt01.status|root.ln.wf02.wt02.hardware|\n+-----------------------------+------------------------+--------------------------+\n|2017-11-01T00:06:00.000+08:00| false| v1|\n|2017-11-01T00:07:00.000+08:00| false| v1|\n|2017-11-01T00:08:00.000+08:00| false| v1|\n|2017-11-01T00:09:00.000+08:00| false| v1|\n|2017-11-01T00:10:00.000+08:00| true| v2|\n|2017-11-01T00:11:00.000+08:00| false| v1|\n|2017-11-01T16:35:00.000+08:00| true| v2|\n|2017-11-01T16:36:00.000+08:00| false| v1|\n|2017-11-01T16:37:00.000+08:00| false| v1|\n+-----------------------------+------------------------+--------------------------+\nTotal line number = 9\nIt costs 0.014s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br")])]),s("h4",{attrs:{id:"order-by-time-query"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#order-by-time-query"}},[e._v("#")]),e._v(" Order By Time Query")]),e._v(" "),s("p",[e._v("IoTDB supports the 'order by time' statement since 0.11, it's used to display results in descending order by time.\nFor example, the SQL statement is:")]),e._v(" "),s("div",{staticClass:"language-sql line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("select")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("*")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("from")]),e._v(" root"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),e._v("ln "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("where")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("time")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("1")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("order")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("by")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("time")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("desc")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("limit")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("10")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The execution result of this SQL statement is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+\n| Time|root.ln.wf02.wt02.hardware|root.ln.wf02.wt02.status|root.ln.wf01.wt01.temperature|root.ln.wf01.wt01.status|\n+-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+\n|2017-11-07T23:59:00.000+08:00| v1| false| 21.07| false|\n|2017-11-07T23:58:00.000+08:00| v1| false| 22.93| false|\n|2017-11-07T23:57:00.000+08:00| v2| true| 24.39| true|\n|2017-11-07T23:56:00.000+08:00| v2| true| 24.44| true|\n|2017-11-07T23:55:00.000+08:00| v2| true| 25.9| true|\n|2017-11-07T23:54:00.000+08:00| v1| false| 22.52| false|\n|2017-11-07T23:53:00.000+08:00| v2| true| 24.58| true|\n|2017-11-07T23:52:00.000+08:00| v1| false| 20.18| false|\n|2017-11-07T23:51:00.000+08:00| v1| false| 22.24| false|\n|2017-11-07T23:50:00.000+08:00| v2| true| 23.7| true|\n+-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+\nTotal line number = 10\nIt costs 0.016s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br"),s("span",{staticClass:"line-number"},[e._v("16")]),s("br")])]),s("h3",{attrs:{id:"time-series-generating-functions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#time-series-generating-functions"}},[e._v("#")]),e._v(" Time Series Generating Functions")]),e._v(" "),s("p",[e._v("The time series generating function takes several time series as input and outputs one time series. Unlike the aggregation function, the result set of the time series generating function has a timestamp column.")]),e._v(" "),s("p",[e._v("All time series generating functions can accept * as input.")]),e._v(" "),s("p",[e._v("IoTDB supports hybrid queries of time series generating function queries and raw data queries.")]),e._v(" "),s("h4",{attrs:{id:"mathematical-functions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#mathematical-functions"}},[e._v("#")]),e._v(" Mathematical Functions")]),e._v(" "),s("p",[e._v("Currently IoTDB supports the following mathematical functions. The behavior of these mathematical functions is consistent with the behavior of these functions in the Java Math standard library.")]),e._v(" "),s("table",[s("thead",[s("tr",[s("th",[e._v("Function Name")]),e._v(" "),s("th",[e._v("Allowed Input Series Data Types")]),e._v(" "),s("th",[e._v("Output Series Data Type")]),e._v(" "),s("th",[e._v("Corresponding Implementation in the Java Standard Library")])])]),e._v(" "),s("tbody",[s("tr",[s("td",[e._v("SIN")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#sin(double)")])]),e._v(" "),s("tr",[s("td",[e._v("COS")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#cos(double)")])]),e._v(" "),s("tr",[s("td",[e._v("TAN")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#tan(double)")])]),e._v(" "),s("tr",[s("td",[e._v("ASIN")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#asin(double)")])]),e._v(" "),s("tr",[s("td",[e._v("ACOS")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#acos(double)")])]),e._v(" "),s("tr",[s("td",[e._v("ATAN")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#atan(double)")])]),e._v(" "),s("tr",[s("td",[e._v("DEGREES")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#toDegrees(double)")])]),e._v(" "),s("tr",[s("td",[e._v("RADIANS")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#toRadians(double)")])]),e._v(" "),s("tr",[s("td",[e._v("ABS")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("Same type as the input series")]),e._v(" "),s("td",[e._v("Math#abs(int) / Math#abs(long) /Math#abs(float) /Math#abs(double)")])]),e._v(" "),s("tr",[s("td",[e._v("SIGN")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#signum(double)")])]),e._v(" "),s("tr",[s("td",[e._v("CEIL")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#ceil(double)")])]),e._v(" "),s("tr",[s("td",[e._v("FLOOR")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#floor(double)")])]),e._v(" "),s("tr",[s("td",[e._v("ROUND")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#rint(double)")])]),e._v(" "),s("tr",[s("td",[e._v("EXP")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#exp(double)")])]),e._v(" "),s("tr",[s("td",[e._v("LN")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#log(double)")])]),e._v(" "),s("tr",[s("td",[e._v("LOG10")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#log10(double)")])]),e._v(" "),s("tr",[s("td",[e._v("SQRT")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Math#sqrt(double)")])])])]),e._v(" "),s("p",[e._v("Example:")]),e._v(" "),s("div",{staticClass:"language-sql line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("select")]),e._v(" s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" sin"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" cos"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" tan"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("from")]),e._v(" root"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),e._v("sg1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),e._v("d1 "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("limit")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("5")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("offset")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("1000")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------+-------------------+--------------------+-------------------+\n| Time| root.sg1.d1.s1|sin(root.sg1.d1.s1)| cos(root.sg1.d1.s1)|tan(root.sg1.d1.s1)|\n+-----------------------------+-------------------+-------------------+--------------------+-------------------+\n|2020-12-10T17:11:49.037+08:00|7360723084922759782| 0.8133527237573284| 0.5817708713544664| 1.3980636773094157|\n|2020-12-10T17:11:49.038+08:00|4377791063319964531|-0.8938962705202537| 0.4482738644511651| -1.994085181866842|\n|2020-12-10T17:11:49.039+08:00|7972485567734642915| 0.9627757585308978|-0.27030138509681073|-3.5618602479083545|\n|2020-12-10T17:11:49.040+08:00|2508858212791964081|-0.6073417341629443| -0.7944406950452296| 0.7644897069734913|\n|2020-12-10T17:11:49.041+08:00|2817297431185141819|-0.8419358900502509| -0.5395775727782725| 1.5603611649667768|\n+-----------------------------+-------------------+-------------------+--------------------+-------------------+\nTotal line number = 5\nIt costs 0.008s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br")])]),s("h4",{attrs:{id:"string-processing-functions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#string-processing-functions"}},[e._v("#")]),e._v(" String Processing Functions")]),e._v(" "),s("p",[e._v("Currently IoTDB supports the following string processing functions:")]),e._v(" "),s("table",[s("thead",[s("tr",[s("th",[e._v("Function Name")]),e._v(" "),s("th",[e._v("Allowed Input Series Data Types")]),e._v(" "),s("th",[e._v("Required Attributes")]),e._v(" "),s("th",[e._v("Output Series Data Type")]),e._v(" "),s("th",[e._v("Description")])])]),e._v(" "),s("tbody",[s("tr",[s("td",[e._v("STRING_CONTAINS")]),e._v(" "),s("td",[e._v("TEXT")]),e._v(" "),s("td",[s("code",[e._v("s")]),e._v(": the sequence to search for")]),e._v(" "),s("td",[e._v("BOOLEAN")]),e._v(" "),s("td",[e._v("Determine whether "),s("code",[e._v("s")]),e._v(" is in the string")])]),e._v(" "),s("tr",[s("td",[e._v("STRING_MATCHES")]),e._v(" "),s("td",[e._v("TEXT")]),e._v(" "),s("td",[s("code",[e._v("regex")]),e._v(": the regular expression to which the string is to be matched")]),e._v(" "),s("td",[e._v("BOOLEAN")]),e._v(" "),s("td",[e._v("Determine whether the string can be matched by "),s("code",[e._v("regex")])])])])]),e._v(" "),s("p",[e._v("Example:")]),e._v(" "),s("div",{staticClass:"language-sql line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("select")]),e._v(" s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" string_contains"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[e._v('"s"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),s("span",{pre:!0,attrs:{class:"token string"}},[e._v('"warn"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" string_matches"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[e._v('"regex"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),s("span",{pre:!0,attrs:{class:"token string"}},[e._v('"[^\\\\s]+37229"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("from")]),e._v(" root"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),e._v("sg1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),e._v("d4"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v('+-----------------------------+--------------+-------------------------------------------+------------------------------------------------------+\n| Time|root.sg1.d4.s1|string_contains(root.sg1.d4.s1, "s"="warn")|string_matches(root.sg1.d4.s1, "regex"="[^\\\\s]+37229")|\n+-----------------------------+--------------+-------------------------------------------+------------------------------------------------------+\n|1970-01-01T08:00:00.001+08:00| warn:-8721| true| false|\n|1970-01-01T08:00:00.002+08:00| error:-37229| false| true|\n|1970-01-01T08:00:00.003+08:00| warn:1731| true| false|\n+-----------------------------+--------------+-------------------------------------------+------------------------------------------------------+\nTotal line number = 3\nIt costs 0.007s\n')])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br")])]),s("h4",{attrs:{id:"selector-functions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#selector-functions"}},[e._v("#")]),e._v(" Selector Functions")]),e._v(" "),s("p",[e._v("Currently IoTDB supports the following selector functions:")]),e._v(" "),s("table",[s("thead",[s("tr",[s("th",[e._v("Function Name")]),e._v(" "),s("th",[e._v("Allowed Input Series Data Types")]),e._v(" "),s("th",[e._v("Required Attributes")]),e._v(" "),s("th",[e._v("Output Series Data Type")]),e._v(" "),s("th",[e._v("Description")])])]),e._v(" "),s("tbody",[s("tr",[s("td",[e._v("TOP_K")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE / TEXT")]),e._v(" "),s("td",[s("code",[e._v("k")]),e._v(": the maximum number of selected data points, must be greater than 0 and less than or equal to 1000")]),e._v(" "),s("td",[e._v("Same type as the input series")]),e._v(" "),s("td",[e._v("Returns "),s("code",[e._v("k")]),e._v(" data points with the largest values in a time series.")])]),e._v(" "),s("tr",[s("td",[e._v("BOTTOM_K")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE / TEXT")]),e._v(" "),s("td",[s("code",[e._v("k")]),e._v(": the maximum number of selected data points, must be greater than 0 and less than or equal to 1000")]),e._v(" "),s("td",[e._v("Same type as the input series")]),e._v(" "),s("td",[e._v("Returns "),s("code",[e._v("k")]),e._v(" data points with the smallest values in a time series.")])])])]),e._v(" "),s("p",[e._v("Example:")]),e._v(" "),s("div",{staticClass:"language-sql line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("select")]),e._v(" s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" top_k"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[e._v('"k"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),s("span",{pre:!0,attrs:{class:"token string"}},[e._v('"2"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" bottom_k"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[e._v('"k"')]),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("=")]),s("span",{pre:!0,attrs:{class:"token string"}},[e._v('"2"')]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("from")]),e._v(" root"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),e._v("sg1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),e._v("d2 "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("where")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("time")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v(">")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("2020")]),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("-")]),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("12")]),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("-")]),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("10")]),e._v("T20:"),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("36")]),e._v(":"),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("15.530")]),s("span",{pre:!0,attrs:{class:"token operator"}},[e._v("+")]),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("08")]),e._v(":"),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("00")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v("\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v('+-----------------------------+--------------------+------------------------------+---------------------------------+\n| Time| root.sg1.d2.s1|top_k(root.sg1.d2.s1, "k"="2")|bottom_k(root.sg1.d2.s1, "k"="2")|\n+-----------------------------+--------------------+------------------------------+---------------------------------+\n|2020-12-10T20:36:15.531+08:00| 1531604122307244742| 1531604122307244742| null|\n|2020-12-10T20:36:15.532+08:00|-7426070874923281101| null| null|\n|2020-12-10T20:36:15.533+08:00|-7162825364312197604| -7162825364312197604| null|\n|2020-12-10T20:36:15.534+08:00|-8581625725655917595| null| -8581625725655917595|\n|2020-12-10T20:36:15.535+08:00|-7667364751255535391| null| -7667364751255535391|\n+-----------------------------+--------------------+------------------------------+---------------------------------+\nTotal line number = 5\nIt costs 0.006s\n')])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br")])]),s("h4",{attrs:{id:"variation-trend-calculation-functions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#variation-trend-calculation-functions"}},[e._v("#")]),e._v(" Variation Trend Calculation Functions")]),e._v(" "),s("p",[e._v("Currently IoTDB supports the following variation trend calculation functions:")]),e._v(" "),s("table",[s("thead",[s("tr",[s("th",[e._v("Function Name")]),e._v(" "),s("th",[e._v("Allowed Input Series Data Types")]),e._v(" "),s("th",[e._v("Output Series Data Type")]),e._v(" "),s("th",[e._v("Description")])])]),e._v(" "),s("tbody",[s("tr",[s("td",[e._v("TIME_DIFFERENCE")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE / BOOLEAN / TEXT")]),e._v(" "),s("td",[e._v("INT64")]),e._v(" "),s("td",[e._v("Calculates the difference between the time stamp of a data point and the time stamp of the previous data point. There is no corresponding output for the first data point.")])]),e._v(" "),s("tr",[s("td",[e._v("DIFFERENCE")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("Same type as the input series")]),e._v(" "),s("td",[e._v("Calculates the difference between the value of a data point and the value of the previous data point. There is no corresponding output for the first data point.")])]),e._v(" "),s("tr",[s("td",[e._v("NON_NEGATIVE_DIFFERENCE")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("Same type as the input series")]),e._v(" "),s("td",[e._v("Calculates the absolute value of the difference between the value of a data point and the value of the previous data point. There is no corresponding output for the first data point.")])]),e._v(" "),s("tr",[s("td",[e._v("DERIVATIVE")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Calculates the rate of change of a data point compared to the previous data point, the result is equals to DIFFERENCE / TIME_DIFFERENCE. There is no corresponding output for the first data point.")])]),e._v(" "),s("tr",[s("td",[e._v("NON_NEGATIVE_DERIVATIVE")]),e._v(" "),s("td",[e._v("INT32 / INT64 / FLOAT / DOUBLE")]),e._v(" "),s("td",[e._v("DOUBLE")]),e._v(" "),s("td",[e._v("Calculates the absolute value of the rate of change of a data point compared to the previous data point, the result is equals to NON_NEGATIVE_DIFFERENCE / TIME_DIFFERENCE. There is no corresponding output for the first data point.")])])])]),e._v(" "),s("p",[e._v("Example:")]),e._v(" "),s("div",{staticClass:"language-sql line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-sql"}},[s("code",[s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("select")]),e._v(" s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" time_difference"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" difference"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" non_negative_difference"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" derivative"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(",")]),e._v(" non_negative_derivative"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("(")]),e._v("s1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(")")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("from")]),e._v(" root"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),e._v("sg1"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(".")]),e._v("d1 "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("limit")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("5")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token keyword"}},[e._v("offset")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token number"}},[e._v("1000")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(";")]),e._v(" \n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------+-------------------------------+--------------------------+---------------------------------------+--------------------------+---------------------------------------+\n| 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)|\n+-----------------------------+-------------------+-------------------------------+--------------------------+---------------------------------------+--------------------------+---------------------------------------+\n|2020-12-10T17:11:49.037+08:00|7360723084922759782| 1| -8431715764844238876| 8431715764844238876| -8.4317157648442388E18| 8.4317157648442388E18|\n|2020-12-10T17:11:49.038+08:00|4377791063319964531| 1| -2982932021602795251| 2982932021602795251| -2.982932021602795E18| 2.982932021602795E18|\n|2020-12-10T17:11:49.039+08:00|7972485567734642915| 1| 3594694504414678384| 3594694504414678384| 3.5946945044146785E18| 3.5946945044146785E18|\n|2020-12-10T17:11:49.040+08:00|2508858212791964081| 1| -5463627354942678834| 5463627354942678834| -5.463627354942679E18| 5.463627354942679E18|\n|2020-12-10T17:11:49.041+08:00|2817297431185141819| 1| 308439218393177738| 308439218393177738| 3.0843921839317773E17| 3.0843921839317773E17|\n+-----------------------------+-------------------+-------------------------------+--------------------------+---------------------------------------+--------------------------+---------------------------------------+\nTotal line number = 5\nIt costs 0.014s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br")])]),s("h4",{attrs:{id:"user-defined-timeseries-generating-functions"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#user-defined-timeseries-generating-functions"}},[e._v("#")]),e._v(" User Defined Timeseries Generating Functions")]),e._v(" "),s("p",[e._v("Please refer to "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/UDF User Defined Function.html"}},[e._v("UDF (User Defined Function)")]),e._v(".")],1),e._v(" "),s("h3",{attrs:{id:"aggregate-query"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#aggregate-query"}},[e._v("#")]),e._v(" Aggregate Query")]),e._v(" "),s("p",[e._v("This section mainly introduces the related examples of aggregate query.")]),e._v(" "),s("h4",{attrs:{id:"count-points"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#count-points"}},[e._v("#")]),e._v(" Count Points")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select count(status) from root.ln.wf01.wt01;\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-------------------------------+\n|count(root.ln.wf01.wt01.status)|\n+-------------------------------+\n| 10080|\n+-------------------------------+\nTotal line number = 1\nIt costs 0.016s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br")])]),s("h5",{attrs:{id:"aggregation-by-level"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#aggregation-by-level"}},[e._v("#")]),e._v(" Aggregation By Level")]),e._v(" "),s("p",[s("strong",[e._v("Aggregation by level statement")]),e._v(' is used for aggregating upon specific hierarchical level of timeseries path.\nFor all timeseries paths, by convention, "level=0" represents '),s("em",[e._v("root")]),e._v(' level.\nThat is, to tally the points of any measurements under "root.ln", the level should be set to 1.')]),e._v(" "),s("p",[e._v('For example, there are multiple series under "root.ln.wf01", such as "root.ln.wf01.wt01.status","root.ln.wf01.wt02.status","root.ln.wf01.wt03.status".\nTo count the number of "status" points of all these series, use query:')]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select count(status) from root.ln.wf01.* group by level=2\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+----------------------------+\n|COUNT(root.ln.wf01.*.status)|\n+----------------------------+\n| 10080|\n+----------------------------+\nTotal line number = 1\nIt costs 0.003s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br")])]),s("p",[e._v('Suppose we add another two timeseries, "root.ln.wf01.wt01.temperature" and "root.ln.wf02.wt01.temperature".\nTo query the count and the sum of "temperature" under path "root.ln.'),s("em",[e._v(".")]),e._v('",\naggregating on level=2, use following statement:')]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select count(temperature), sum(temperature) from root.ln.*.* group by level=2\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+---------------------------------+---------------------------------+-------------------------------+-------------------------------+\n|count(root.ln.wf02.*.temperature)|count(root.ln.wf01.*.temperature)|sum(root.ln.wf02.*.temperature)|sum(root.ln.wf01.*.temperature)|\n+---------------------------------+---------------------------------+-------------------------------+-------------------------------+\n| 8| 4| 228.0| 91.83000183105469|\n+---------------------------------+---------------------------------+-------------------------------+-------------------------------+\nTotal line number = 1\nIt costs 0.013s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br")])]),s("p",[e._v('To query the count and the sum of path "root.ln.*.*.temperature" aggregating on "root.ln" level,\nsimply set level=1')]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select count(temperature), sum(temperature) from root.ln.*.* group by level=1\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+------------------------------+----------------------------+\n|count(root.ln.*.*.temperature)|sum(root.ln.*.*.temperature)|\n+------------------------------+----------------------------+\n| 12| 319.8300018310547|\n+------------------------------+----------------------------+\nTotal line number = 1\nIt costs 0.013s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br")])]),s("p",[e._v("All supported aggregation functions are: count, sum, avg, last_value, first_value, min_time, max_time, min_value, max_value.\nWhen using four aggregations: sum, avg, min_value and max_value, please make sure all the aggregated series have exactly the same data type.\nOtherwise, it will generate a syntax error.")]),e._v(" "),s("h3",{attrs:{id:"down-frequency-aggregate-query"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query")]),e._v(" "),s("p",[e._v("This section mainly introduces the related examples of down-frequency aggregation query,\nusing the "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("GROUP BY clause")]),e._v(",\nwhich is used to partition the result set according to the user's given partitioning conditions and aggregate the partitioned result set.\nIoTDB supports partitioning result sets according to time interval and customized sliding step which should not be smaller than the time interval and defaults to equal the time interval if not set. And by default results are sorted by time in ascending order.\nYou can also use the "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Client/Programming - Native API.html"}},[e._v("Java JDBC")]),e._v(" standard interface to execute related queries.")],1),e._v(" "),s("p",[e._v("The GROUP BY statement provides users with three types of specified parameters:")]),e._v(" "),s("ul",[s("li",[e._v("Parameter 1: The display window on the time axis")]),e._v(" "),s("li",[e._v("Parameter 2: Time interval for dividing the time axis(should be positive)")]),e._v(" "),s("li",[e._v("Parameter 3: Time sliding step (optional and should not be smaller than the time interval and defaults to equal the time interval if not set)")])]),e._v(" "),s("p",[e._v("The actual meanings of the three types of parameters are shown in Figure 5.2 below.\nAmong them, the parameter 3 is optional.\nThere are three typical examples of frequency reduction aggregation:\nparameter 3 not specified,\nparameter 3 specified,\nand value filtering conditions specified.")]),e._v(" "),s("center",[s("img",{staticStyle:{width:"100%","max-width":"800px","max-height":"600px","margin-left":"auto","margin-right":"auto",display:"block"},attrs:{src:"https://user-images.githubusercontent.com/16079446/69109512-f808bc80-0ab2-11ea-9e4d-b2b2f58fb474.png"}})]),e._v(" "),s("p",[s("strong",[e._v("Figure 5.2 The actual meanings of the three types of parameters")])]),e._v(" "),s("h4",{attrs:{id:"down-frequency-aggregate-query-without-specifying-the-sliding-step-length"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query-without-specifying-the-sliding-step-length"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query without Specifying the Sliding Step Length")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select count(status), max_value(temperature) from root.ln.wf01.wt01 group by ([2017-11-01T00:00:00, 2017-11-07T23:00:00),1d);\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("Since the sliding step length is not specified, the GROUP BY statement by default set the sliding step the same as the time interval which is "),s("code",[e._v("1d")]),e._v(".")]),e._v(" "),s("p",[e._v("The fist parameter of the GROUP BY statement above is the display window parameter, which determines the final display range is [2017-11-01T00:00:00, 2017-11-07T23:00:00).")]),e._v(" "),s("p",[e._v("The second parameter of the GROUP BY statement above is the time interval for dividing the time axis. Taking this parameter (1d) as time interval and startTime of the display window as the dividing origin, the time axis is divided into several continuous intervals, which are [0,1d), [1d, 2d), [2d, 3d), etc.")]),e._v(" "),s("p",[e._v("Then the system will use the time and value filtering condition in the WHERE clause and the first parameter of the GROUP BY statement as the data filtering condition to obtain the data satisfying the filtering condition (which in this case is the data in the range of [2017-11-01T00:00:00, 2017-11-07 T23:00:00]), and map these data to the previously segmented time axis (in this case there are mapped data in every 1-day period from 2017-11-01T00:00:00 to 2017-11-07T23:00:00:00).")]),e._v(" "),s("p",[e._v("Since there is data for each time period in the result range to be displayed, the execution result of the SQL statement is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------------+----------------------------------------+\n| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|\n+-----------------------------+-------------------------------+----------------------------------------+\n|2017-11-01T00:00:00.000+08:00| 1440| 26.0|\n|2017-11-02T00:00:00.000+08:00| 1440| 26.0|\n|2017-11-03T00:00:00.000+08:00| 1440| 25.99|\n|2017-11-04T00:00:00.000+08:00| 1440| 26.0|\n|2017-11-05T00:00:00.000+08:00| 1440| 26.0|\n|2017-11-06T00:00:00.000+08:00| 1440| 25.99|\n|2017-11-07T00:00:00.000+08:00| 1380| 26.0|\n+-----------------------------+-------------------------------+----------------------------------------+\nTotal line number = 7\nIt costs 0.024s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br")])]),s("h4",{attrs:{id:"down-frequency-aggregate-query-specifying-the-sliding-step-length"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query-specifying-the-sliding-step-length"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query Specifying the Sliding Step Length")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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);\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("Since the user specifies the sliding step parameter as 1d, the GROUP BY statement will move the time interval "),s("code",[e._v("1 day")]),e._v(" long instead of "),s("code",[e._v("3 hours")]),e._v(" as default.")]),e._v(" "),s("p",[e._v("That means we want to fetch all the data of 00:00:00 to 02:59:59 every day from 2017-11-01 to 2017-11-07.")]),e._v(" "),s("p",[e._v("The first parameter of the GROUP BY statement above is the display window parameter, which determines the final display range is [2017-11-01T00:00:00, 2017-11-07T23:00:00).")]),e._v(" "),s("p",[e._v("The second parameter of the GROUP BY statement above is the time interval for dividing the time axis. Taking this parameter (3h) as time interval and the startTime of the display window as the dividing origin, the time axis is divided into several continuous intervals, which are [2017-11-01T00:00:00, 2017-11-01T03:00:00), [2017-11-02T00:00:00, 2017-11-02T03:00:00), [2017-11-03T00:00:00, 2017-11-03T03:00:00), etc.")]),e._v(" "),s("p",[e._v("The third parameter of the GROUP BY statement above is the sliding step for each time interval moving.")]),e._v(" "),s("p",[e._v("Then the system will use the time and value filtering condition in the WHERE clause and the first parameter of the GROUP BY statement as the data filtering condition to obtain the data satisfying the filtering condition (which in this case is the data in the range of [2017-11-01T00:00:00, 2017-11-07T23:00:00]), and map these data to the previously segmented time axis (in this case there are mapped data in every 3-hour period for each day from 2017-11-01T00:00:00 to 2017-11-07T23:00:00:00).")]),e._v(" "),s("p",[e._v("Since there is data for each time period in the result range to be displayed, the execution result of the SQL statement is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------------+----------------------------------------+\n| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|\n+-----------------------------+-------------------------------+----------------------------------------+\n|2017-11-01T00:00:00.000+08:00| 180| 25.98|\n|2017-11-02T00:00:00.000+08:00| 180| 25.98|\n|2017-11-03T00:00:00.000+08:00| 180| 25.96|\n|2017-11-04T00:00:00.000+08:00| 180| 25.96|\n|2017-11-05T00:00:00.000+08:00| 180| 26.0|\n|2017-11-06T00:00:00.000+08:00| 180| 25.85|\n|2017-11-07T00:00:00.000+08:00| 180| 25.99|\n+-----------------------------+-------------------------------+----------------------------------------+\nTotal line number = 7\nIt costs 0.006s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br")])]),s("h4",{attrs:{id:"down-frequency-aggregate-query-by-natural-month"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query-by-natural-month"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query by Natural Month")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select count(status) from root.ln.wf01.wt01 group by([2017-11-01T00:00:00, 2019-11-07T23:00:00), 1mo, 2mo);\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("Since the user specifies the sliding step parameter as "),s("code",[e._v("2mo")]),e._v(", the GROUP BY statement will move the time interval "),s("code",[e._v("2 months")]),e._v(" long instead of "),s("code",[e._v("1 month")]),e._v(" as default.")]),e._v(" "),s("p",[e._v("The first parameter of the GROUP BY statement above is the display window parameter, which determines the final display range is [2017-11-01T00:00:00, 2019-11-07T23:00:00).")]),e._v(" "),s("p",[e._v("The start time is 2017-11-01T00:00:00. The sliding step will increment monthly based on the start date, and the 1st day of the month will be used as the time interval's start time.")]),e._v(" "),s("p",[e._v("The second parameter of the GROUP BY statement above is the time interval for dividing the time axis. Taking this parameter (1mo) as time interval and the startTime of the display window as the dividing origin, the time axis is divided into several continuous intervals, which are [2017-11-01T00:00:00, 2017-12-01T00:00:00), [2018-02-01T00:00:00, 2018-03-01T00:00:00), [2018-05-03T00:00:00, 2018-06-01T00:00:00)), etc.")]),e._v(" "),s("p",[e._v("The third parameter of the GROUP BY statement above is the sliding step for each time interval moving.")]),e._v(" "),s("p",[e._v("Then the system will use the time and value filtering condition in the WHERE clause and the first parameter of the GROUP BY statement as the data filtering condition to obtain the data satisfying the filtering condition (which in this case is the data in the range of (2017-11-01T00:00:00, 2019-11-07T23:00:00], and map these data to the previously segmented time axis (in this case there are mapped data of the first month in every two month period from 2017-11-01T00:00:00 to 2019-11-07T23:00:00).")]),e._v(" "),s("p",[e._v("The SQL execution result is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------------+\n| Time|count(root.ln.wf01.wt01.status)|\n+-----------------------------+-------------------------------+\n|2017-11-01T00:00:00.000+08:00| 259|\n|2018-01-01T00:00:00.000+08:00| 250|\n|2018-03-01T00:00:00.000+08:00| 259|\n|2018-05-01T00:00:00.000+08:00| 251|\n|2018-07-01T00:00:00.000+08:00| 242|\n|2018-09-01T00:00:00.000+08:00| 225|\n|2018-11-01T00:00:00.000+08:00| 216|\n|2019-01-01T00:00:00.000+08:00| 207|\n|2019-03-01T00:00:00.000+08:00| 216|\n|2019-05-01T00:00:00.000+08:00| 207|\n|2019-07-01T00:00:00.000+08:00| 199|\n|2019-09-01T00:00:00.000+08:00| 181|\n|2019-11-01T00:00:00.000+08:00| 60|\n+-----------------------------+-------------------------------+\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br"),s("span",{staticClass:"line-number"},[e._v("16")]),s("br"),s("span",{staticClass:"line-number"},[e._v("17")]),s("br")])]),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select count(status) from root.ln.wf01.wt01 group by([2017-10-31T00:00:00, 2019-11-07T23:00:00), 1mo, 2mo);\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("Since the user specifies the sliding step parameter as "),s("code",[e._v("2mo")]),e._v(", the GROUP BY statement will move the time interval "),s("code",[e._v("2 months")]),e._v(" long instead of "),s("code",[e._v("1 month")]),e._v(" as default.")]),e._v(" "),s("p",[e._v("The first parameter of the GROUP BY statement above is the display window parameter, which determines the final display range is [2017-10-31T00:00:00, 2019-11-07T23:00:00).")]),e._v(" "),s("p",[e._v("Different from the previous example, the start time is set to 2017-10-31T00:00:00. The sliding step will increment monthly based on the start date, and the 31st day of the month meaning the last day of the month will be used as the time interval's start time. If the start time is set to the 30th date, the sliding step will use the 30th or the last day of the month.")]),e._v(" "),s("p",[e._v("The start time is 2017-10-31T00:00:00. The sliding step will increment monthly based on the start time, and the 1st day of the month will be used as the time interval's start time.")]),e._v(" "),s("p",[e._v("The second parameter of the GROUP BY statement above is the time interval for dividing the time axis. Taking this parameter (1mo) as time interval and the startTime of the display window as the dividing origin, the time axis is divided into several continuous intervals, which are [2017-10-31T00:00:00, 2017-11-31T00:00:00), [2018-02-31T00:00:00, 2018-03-31T00:00:00), [2018-05-31T00:00:00, 2018-06-31T00:00:00), etc.")]),e._v(" "),s("p",[e._v("The third parameter of the GROUP BY statement above is the sliding step for each time interval moving.")]),e._v(" "),s("p",[e._v("Then the system will use the time and value filtering condition in the WHERE clause and the first parameter of the GROUP BY statement as the data filtering condition to obtain the data satisfying the filtering condition (which in this case is the data in the range of [2017-10-31T00:00:00, 2019-11-07T23:00:00) and map these data to the previously segmented time axis (in this case there are mapped data of the first month in every two month period from 2017-10-31T00:00:00 to 2019-11-07T23:00:00).")]),e._v(" "),s("p",[e._v("The SQL execution result is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------------+\n| Time|count(root.ln.wf01.wt01.status)|\n+-----------------------------+-------------------------------+\n|2017-10-31T00:00:00.000+08:00| 251|\n|2017-12-31T00:00:00.000+08:00| 250|\n|2018-02-28T00:00:00.000+08:00| 259|\n|2018-04-30T00:00:00.000+08:00| 250|\n|2018-06-30T00:00:00.000+08:00| 242|\n|2018-08-31T00:00:00.000+08:00| 225|\n|2018-10-31T00:00:00.000+08:00| 216|\n|2018-12-31T00:00:00.000+08:00| 208|\n|2019-02-28T00:00:00.000+08:00| 216|\n|2019-04-30T00:00:00.000+08:00| 208|\n|2019-06-30T00:00:00.000+08:00| 199|\n|2019-08-31T00:00:00.000+08:00| 181|\n|2019-10-31T00:00:00.000+08:00| 69|\n+-----------------------------+-------------------------------+\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br"),s("span",{staticClass:"line-number"},[e._v("16")]),s("br"),s("span",{staticClass:"line-number"},[e._v("17")]),s("br")])]),s("h4",{attrs:{id:"left-open-and-right-close-range"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#left-open-and-right-close-range"}},[e._v("#")]),e._v(" Left Open And Right Close Range")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d);\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("In this sql, the time interval is left open and right close, so we won't include the value of timestamp 2017-11-01T00:00:00 and instead we will include the value of timestamp 2017-11-07T23:00:00.")]),e._v(" "),s("p",[e._v("We will get the result like following:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------------+\n| Time|count(root.ln.wf01.wt01.status)|\n+-----------------------------+-------------------------------+\n|2017-11-02T00:00:00.000+08:00| 1440|\n|2017-11-03T00:00:00.000+08:00| 1440|\n|2017-11-04T00:00:00.000+08:00| 1440|\n|2017-11-05T00:00:00.000+08:00| 1440|\n|2017-11-06T00:00:00.000+08:00| 1440|\n|2017-11-07T00:00:00.000+08:00| 1440|\n|2017-11-07T23:00:00.000+08:00| 1380|\n+-----------------------------+-------------------------------+\nTotal line number = 7\nIt costs 0.004s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br")])]),s("h4",{attrs:{id:"down-frequency-aggregate-query-with-level-clause"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query-with-level-clause"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query with Level Clause")]),e._v(" "),s("p",[e._v("Level could be defined to show count the number of points of each node at the given level in current Metadata Tree.")]),e._v(" "),s("p",[e._v("This could be used to query the number of points under each device.")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("p",[e._v("Get down-frequency aggregate query by level.")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select count(status) from root.ln.wf01.wt01 group by ((2017-11-01T00:00:00, 2017-11-07T23:00:00],1d), level=1;\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------+\n| Time|COUNT(root.ln.*.*.status)|\n+-----------------------------+-------------------------+\n|2017-11-02T00:00:00.000+08:00| 1440|\n|2017-11-03T00:00:00.000+08:00| 1440|\n|2017-11-04T00:00:00.000+08:00| 1440|\n|2017-11-05T00:00:00.000+08:00| 1440|\n|2017-11-06T00:00:00.000+08:00| 1440|\n|2017-11-07T00:00:00.000+08:00| 1440|\n|2017-11-07T23:00:00.000+08:00| 1380|\n+-----------------------------+-------------------------+\nTotal line number = 7\nIt costs 0.006s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br")])]),s("p",[e._v("Down-frequency aggregate query with sliding step and by level.")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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;\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------+\n| Time|COUNT(root.ln.*.*.status)|\n+-----------------------------+-------------------------+\n|2017-11-01T00:00:00.000+08:00| 180|\n|2017-11-02T00:00:00.000+08:00| 180|\n|2017-11-03T00:00:00.000+08:00| 180|\n|2017-11-04T00:00:00.000+08:00| 180|\n|2017-11-05T00:00:00.000+08:00| 180|\n|2017-11-06T00:00:00.000+08:00| 180|\n|2017-11-07T00:00:00.000+08:00| 180|\n+-----------------------------+-------------------------+\nTotal line number = 7\nIt costs 0.004s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br")])]),s("h4",{attrs:{id:"down-frequency-aggregate-query-with-fill-clause"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#down-frequency-aggregate-query-with-fill-clause"}},[e._v("#")]),e._v(" Down-Frequency Aggregate Query with Fill Clause")]),e._v(" "),s("p",[e._v("In group by fill, sliding step is not supported in group by clause")]),e._v(" "),s("p",[e._v("Now, only last_value aggregation function is supported in group by fill.")]),e._v(" "),s("p",[e._v("Linear fill is not supported in group by fill.")]),e._v(" "),s("h5",{attrs:{id:"difference-between-previousuntillast-and-previous"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#difference-between-previousuntillast-and-previous"}},[e._v("#")]),e._v(" Difference Between PREVIOUSUNTILLAST And PREVIOUS")]),e._v(" "),s("ul",[s("li",[e._v("PREVIOUS will fill any null value as long as there exist value is not null before it.")]),e._v(" "),s("li",[e._v("PREVIOUSUNTILLAST won't fill the result whose time is after the last time of that time series.")])]),e._v(" "),s("p",[e._v("first, we check value root.ln.wf01.wt01.temperature when time after 2017-11-07T23:50:00.")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB> SELECT temperature FROM root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00\n+-----------------------------+-----------------------------+\n| Time|root.ln.wf01.wt01.temperature|\n+-----------------------------+-----------------------------+\n|2017-11-07T23:50:00.000+08:00| 23.7|\n|2017-11-07T23:51:00.000+08:00| 22.24|\n|2017-11-07T23:52:00.000+08:00| 20.18|\n|2017-11-07T23:53:00.000+08:00| 24.58|\n|2017-11-07T23:54:00.000+08:00| 22.52|\n|2017-11-07T23:55:00.000+08:00| 25.9|\n|2017-11-07T23:56:00.000+08:00| 24.44|\n|2017-11-07T23:57:00.000+08:00| 24.39|\n|2017-11-07T23:58:00.000+08:00| 22.93|\n|2017-11-07T23:59:00.000+08:00| 21.07|\n+-----------------------------+-----------------------------+\nTotal line number = 10\nIt costs 0.002s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br"),s("span",{staticClass:"line-number"},[e._v("16")]),s("br"),s("span",{staticClass:"line-number"},[e._v("17")]),s("br")])]),s("p",[e._v("we will find the last time and value of root.ln.wf01.wt01.temperature are 2017-11-07T23:59:00 and 21.07 respectively.")]),e._v(" "),s("p",[e._v("Then execute SQL statements:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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]);\nSELECT last_value(temperature) FROM root.ln.wf01.wt01 GROUP BY([2017-11-07T23:50:00, 2017-11-08T00:01:00),1m) FILL (float[PREVIOUS]);\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br")])]),s("p",[e._v("result:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-----------------------------------------+\n| Time|last_value(root.ln.wf01.wt01.temperature)|\n+-----------------------------+-----------------------------------------+\n|2017-11-07T23:50:00.000+08:00| 23.7|\n|2017-11-07T23:51:00.000+08:00| 22.24|\n|2017-11-07T23:52:00.000+08:00| 20.18|\n|2017-11-07T23:53:00.000+08:00| 24.58|\n|2017-11-07T23:54:00.000+08:00| 22.52|\n|2017-11-07T23:55:00.000+08:00| 25.9|\n|2017-11-07T23:56:00.000+08:00| 24.44|\n|2017-11-07T23:57:00.000+08:00| 24.39|\n|2017-11-07T23:58:00.000+08:00| 22.93|\n|2017-11-07T23:59:00.000+08:00| 21.07|\n|2017-11-08T00:00:00.000+08:00| null|\n+-----------------------------+-----------------------------------------+\nTotal line number = 11\nIt costs 0.005s\n\n+-----------------------------+-----------------------------------------+\n| Time|last_value(root.ln.wf01.wt01.temperature)|\n+-----------------------------+-----------------------------------------+\n|2017-11-07T23:50:00.000+08:00| 23.7|\n|2017-11-07T23:51:00.000+08:00| 22.24|\n|2017-11-07T23:52:00.000+08:00| 20.18|\n|2017-11-07T23:53:00.000+08:00| 24.58|\n|2017-11-07T23:54:00.000+08:00| 22.52|\n|2017-11-07T23:55:00.000+08:00| 25.9|\n|2017-11-07T23:56:00.000+08:00| 24.44|\n|2017-11-07T23:57:00.000+08:00| 24.39|\n|2017-11-07T23:58:00.000+08:00| 22.93|\n|2017-11-07T23:59:00.000+08:00| 21.07|\n|2017-11-08T00:00:00.000+08:00| 21.07|\n+-----------------------------+-----------------------------------------+\nTotal line number = 11\nIt costs 0.006s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br"),s("span",{staticClass:"line-number"},[e._v("16")]),s("br"),s("span",{staticClass:"line-number"},[e._v("17")]),s("br"),s("span",{staticClass:"line-number"},[e._v("18")]),s("br"),s("span",{staticClass:"line-number"},[e._v("19")]),s("br"),s("span",{staticClass:"line-number"},[e._v("20")]),s("br"),s("span",{staticClass:"line-number"},[e._v("21")]),s("br"),s("span",{staticClass:"line-number"},[e._v("22")]),s("br"),s("span",{staticClass:"line-number"},[e._v("23")]),s("br"),s("span",{staticClass:"line-number"},[e._v("24")]),s("br"),s("span",{staticClass:"line-number"},[e._v("25")]),s("br"),s("span",{staticClass:"line-number"},[e._v("26")]),s("br"),s("span",{staticClass:"line-number"},[e._v("27")]),s("br"),s("span",{staticClass:"line-number"},[e._v("28")]),s("br"),s("span",{staticClass:"line-number"},[e._v("29")]),s("br"),s("span",{staticClass:"line-number"},[e._v("30")]),s("br"),s("span",{staticClass:"line-number"},[e._v("31")]),s("br"),s("span",{staticClass:"line-number"},[e._v("32")]),s("br"),s("span",{staticClass:"line-number"},[e._v("33")]),s("br"),s("span",{staticClass:"line-number"},[e._v("34")]),s("br"),s("span",{staticClass:"line-number"},[e._v("35")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("using PREVIOUSUNTILLAST won't fill time after 2017-11-07T23:59.")]),e._v(" "),s("h3",{attrs:{id:"last-point-query"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#last-point-query"}},[e._v("#")]),e._v(" Last point Query")]),e._v(" "),s("p",[e._v("In scenarios when IoT devices updates data in a fast manner, users are more interested in the most recent point of IoT devices.")]),e._v(" "),s("p",[e._v("The Last point query is to return the most recent data point of the given timeseries in a three column format.")]),e._v(" "),s("p",[e._v("The SQL statement is defined as:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select last <Path> [COMMA <Path>]* from < PrefixPath > [COMMA < PrefixPath >]* <WhereClause>\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means: Query and return the last data points of timeseries prefixPath.path.")]),e._v(" "),s("p",[e._v("Only time filter with '>' or '>=' is supported in <WhereClause>. Any other filters given in the <WhereClause> will give an exception.")]),e._v(" "),s("p",[e._v("The result will be returned in a three column table format.")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("| Time | Path | Value |\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Example 1: get the last point of root.ln.wf01.wt01.status:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB> select last status from root.ln.wf01.wt01\n+-----------------------------+------------------------+-----+\n| Time| timeseries|value|\n+-----------------------------+------------------------+-----+\n|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.status|false|\n+-----------------------------+------------------------+-----+\nTotal line number = 1\nIt costs 0.000s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br")])]),s("p",[e._v("Example 2: get the last status and temperature points of root.ln.wf01.wt01,\nwhose timestamp larger or equal to 2017-11-07T23:50:00。")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB> select last status, temperature from root.ln.wf01.wt01 where time >= 2017-11-07T23:50:00\n+-----------------------------+-----------------------------+---------+\n| Time| timeseries| value|\n+-----------------------------+-----------------------------+---------+\n|2017-11-07T23:59:00.000+08:00| root.ln.wf01.wt01.status| false|\n|2017-11-07T23:59:00.000+08:00|root.ln.wf01.wt01.temperature|21.067368|\n+-----------------------------+-----------------------------+---------+\nTotal line number = 2\nIt costs 0.002s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br")])]),s("h3",{attrs:{id:"automated-fill"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#automated-fill"}},[e._v("#")]),e._v(" Automated Fill")]),e._v(" "),s("p",[e._v("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.")]),e._v(" "),s("p",[e._v("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.")]),e._v(" "),s("blockquote",[s("p",[e._v("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.")])]),e._v(" "),s("h4",{attrs:{id:"fill-function"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#fill-function"}},[e._v("#")]),e._v(" Fill Function")]),e._v(" "),s("ul",[s("li",[e._v("Previous Function")])]),e._v(" "),s("p",[e._v("When the value of the queried timestamp is null, the value of the previous timestamp is used to fill the blank. The formalized previous method is as follows (see Section 7.1.3.6 for detailed syntax):")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select <path> from <prefixPath> where time = <T> fill(<data_type>[previous, <before_range>], …)\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Detailed descriptions of all parameters are given in Table 3-4.")]),e._v(" "),s("center",[e._v("**Table 3-4 Previous fill paramter list**\n"),s("table",[s("thead",[s("tr",[s("th",{staticStyle:{"text-align":"left"}},[e._v("Parameter name (case insensitive)")]),e._v(" "),s("th",{staticStyle:{"text-align":"left"}},[e._v("Interpretation")])])]),e._v(" "),s("tbody",[s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("path, prefixPath")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("query path; mandatory field")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("T")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("query timestamp (only one can be specified); mandatory field")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("data_type")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("the type of data used by the fill method. Optional values are int32, int64, float, double, boolean, text; optional field")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("before_range")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("represents the valid time range of the previous method. The previous method works when there are values in the [T-before_range, T] range. When before_range is not specified, before_range takes the default value default_fill_interval; -1 represents infinit; optional field")])])])])]),e._v(" "),s("p",[e._v("Here we give an example of filling null values using the previous method. The SQL statement is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1s]) \n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("Because the timeseries root.sgcc.wf03.wt01.temperature is null at 2017-11-01T16:37:50.000, the system uses the previous timestamp 2017-11-01T16:37:00.000 (and the timestamp is in the [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] time range) for fill and display.")]),e._v(" "),s("p",[e._v("On the "),s("a",{attrs:{href:"https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt",target:"_blank",rel:"noopener noreferrer"}},[e._v("sample data"),s("OutboundLink")],1),e._v(", the execution result of this statement is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------------+\n| Time|root.sgcc.wf03.wt01.temperature|\n+-----------------------------+-------------------------------+\n|2017-11-01T16:37:50.000+08:00| 21.93|\n+-----------------------------+-------------------------------+\nTotal line number = 1\nIt costs 0.016s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br")])]),s("p",[e._v("It is worth noting that if there is no value in the specified valid time range, the system will not fill the null value, as shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB> select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1s]) \n+-----------------------------+-------------------------------+\n| Time|root.sgcc.wf03.wt01.temperature|\n+-----------------------------+-------------------------------+\n|2017-11-01T16:37:50.000+08:00| null|\n+-----------------------------+-------------------------------+\nTotal line number = 1\nIt costs 0.004s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br")])]),s("ul",[s("li",[e._v("Linear Method")])]),e._v(" "),s("p",[e._v("When the value of the queried timestamp is null, the value of the previous and the next timestamp is used to fill the blank. The formalized linear method is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select <path> from <prefixPath> where time = <T> fill(<data_type>[linear, <before_range>, <after_range>]…)\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("Detailed descriptions of all parameters are given in Table 3-5.")]),e._v(" "),s("center",[e._v("**Table 3-5 Linear fill paramter list**\n"),s("table",[s("thead",[s("tr",[s("th",{staticStyle:{"text-align":"left"}},[e._v("Parameter name (case insensitive)")]),e._v(" "),s("th",{staticStyle:{"text-align":"left"}},[e._v("Interpretation")])])]),e._v(" "),s("tbody",[s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("path, prefixPath")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("query path; mandatory field")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("T")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("query timestamp (only one can be specified); mandatory field")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("data_type")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("the type of data used by the fill method. Optional values are int32, int64, float, double, boolean, text; optional field")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("before_range, after_range")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("represents the valid time range of the linear method. The previous method works when there are values in the [T-before_range, T+after_range] range. When before_range and after_range are not explicitly specified, default_fill_interval is used. -1 represents infinity; optional field")])])])])]),e._v(" "),s("p",[s("strong",[e._v("Note")]),e._v(" if the timeseries has a valid value at query timestamp T, this value will be used as the linear fill value.\nOtherwise, if there is no valid fill value in either range [T-before_range,T] or [T, T + after_range], linear fill method will return null.")]),e._v(" "),s("p",[e._v("Here we give an example of filling null values using the linear method. The SQL statement is as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float [linear, 1m, 1m])\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("Because the timeseries root.sgcc.wf03.wt01.temperature is null at 2017-11-01T16:37:50.000, the system uses the previous timestamp 2017-11-01T16:37:00.000 (and the timestamp is in the [2017-11-01T16:36:50.000, 2017-11-01T16:37:50.000] time range) and its value 21.927326, the next timestamp 2017-11-01T16:38:00.000 (and the timestamp is in the [2017-11-01T16:37:50.000, 2017-11-01T16:38:50.000] time range) and its value 25.311783 to perform linear fitting calculation: 21.927326 + (25.311783-21.927326)/60s * 50s = 24.747707")]),e._v(" "),s("p",[e._v("On the "),s("a",{attrs:{href:"https://github.com/thulab/iotdb/files/4438687/OtherMaterial-Sample.Data.txt",target:"_blank",rel:"noopener noreferrer"}},[e._v("sample data"),s("OutboundLink")],1),e._v(", the execution result of this statement is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------------+\n| Time|root.sgcc.wf03.wt01.temperature|\n+-----------------------------+-------------------------------+\n|2017-11-01T16:37:50.000+08:00| 24.746666|\n+-----------------------------+-------------------------------+\nTotal line number = 1\nIt costs 0.017s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br")])]),s("h4",{attrs:{id:"correspondence-between-data-type-and-fill-method"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#correspondence-between-data-type-and-fill-method"}},[e._v("#")]),e._v(" Correspondence between Data Type and Fill Method")]),e._v(" "),s("p",[e._v("Data types and the supported fill methods are shown in Table 3-6.")]),e._v(" "),s("center",[e._v("**Table 3-6 Data types and the supported fill methods**\n"),s("table",[s("thead",[s("tr",[s("th",{staticStyle:{"text-align":"left"}},[e._v("Data Type")]),e._v(" "),s("th",{staticStyle:{"text-align":"left"}},[e._v("Supported Fill Methods")])])]),e._v(" "),s("tbody",[s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("boolean")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("int32")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, linear")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("int64")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, linear")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("float")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, linear")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("double")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, linear")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("text")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous")])])])])]),e._v(" "),s("p",[e._v("When the fill method is not specified, each data type bears its own default fill methods and parameters. The corresponding relationship is shown in Table 3-7.")]),e._v(" "),s("center",[e._v("**Table 3-7 Default fill methods and parameters for various data types**\n"),s("table",[s("thead",[s("tr",[s("th",{staticStyle:{"text-align":"left"}},[e._v("Data Type")]),e._v(" "),s("th",{staticStyle:{"text-align":"left"}},[e._v("Default Fill Methods and Parameters")])])]),e._v(" "),s("tbody",[s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("boolean")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, 600000")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("int32")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, 600000")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("int64")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, 600000")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("float")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, 600000")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("double")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, 600000")])]),e._v(" "),s("tr",[s("td",{staticStyle:{"text-align":"left"}},[e._v("text")]),e._v(" "),s("td",{staticStyle:{"text-align":"left"}},[e._v("previous, 600000")])])])])]),e._v(" "),s("blockquote",[s("p",[e._v("Note: In version 0.7.0, at least one fill method should be specified in the Fill statement.")])]),e._v(" "),s("h3",{attrs:{id:"row-and-column-control-over-query-results"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#row-and-column-control-over-query-results"}},[e._v("#")]),e._v(" Row and Column Control over Query Results")]),e._v(" "),s("p",[e._v("IoTDB provides "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("LIMIT/SLIMIT")]),e._v(" clause and "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("OFFSET/SOFFSET")]),e._v("\nclause in order to make users have more control over query results.\nThe use of LIMIT and SLIMIT clauses allows users to control the number of rows and columns of query results,\nand the use of OFFSET and SOFSET clauses allows users to set the starting position of the results for display.")],1),e._v(" "),s("p",[e._v("Note that the LIMIT and OFFSET are not supported in group by query.")]),e._v(" "),s("p",[e._v("This chapter mainly introduces related examples of row and column control of query results. You can also use the "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Client/Programming - JDBC.html"}},[e._v("Java JDBC")]),e._v(" standard interface to execute queries.")],1),e._v(" "),s("h4",{attrs:{id:"row-control-over-query-results"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#row-control-over-query-results"}},[e._v("#")]),e._v(" Row Control over Query Results")]),e._v(" "),s("p",[e._v("By using LIMIT and OFFSET clauses, users control the query results in a row-related manner. We demonstrate how to use LIMIT and OFFSET clauses through the following examples.")]),e._v(" "),s("ul",[s("li",[e._v("Example 1: basic LIMIT clause")])]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select status, temperature from root.ln.wf01.wt01 limit 10\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature". The SQL statement requires the first 10 rows of the query result.')]),e._v(" "),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+------------------------+-----------------------------+\n| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|\n+-----------------------------+------------------------+-----------------------------+\n|2017-11-01T00:00:00.000+08:00| true| 25.96|\n|2017-11-01T00:01:00.000+08:00| true| 24.36|\n|2017-11-01T00:02:00.000+08:00| false| 20.09|\n|2017-11-01T00:03:00.000+08:00| false| 20.18|\n|2017-11-01T00:04:00.000+08:00| false| 21.13|\n|2017-11-01T00:05:00.000+08:00| false| 22.72|\n|2017-11-01T00:06:00.000+08:00| false| 20.71|\n|2017-11-01T00:07:00.000+08:00| false| 21.45|\n|2017-11-01T00:08:00.000+08:00| false| 22.58|\n|2017-11-01T00:09:00.000+08:00| false| 20.98|\n+-----------------------------+------------------------+-----------------------------+\nTotal line number = 10\nIt costs 0.000s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br"),s("span",{staticClass:"line-number"},[e._v("16")]),s("br")])]),s("ul",[s("li",[e._v("Example 2: LIMIT clause with OFFSET")])]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select status, temperature from root.ln.wf01.wt01 limit 5 offset 3\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature". The SQL statement requires rows 3 to 7 of the query result be returned (with the first row numbered as row 0).')]),e._v(" "),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+------------------------+-----------------------------+\n| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|\n+-----------------------------+------------------------+-----------------------------+\n|2017-11-01T00:03:00.000+08:00| false| 20.18|\n|2017-11-01T00:04:00.000+08:00| false| 21.13|\n|2017-11-01T00:05:00.000+08:00| false| 22.72|\n|2017-11-01T00:06:00.000+08:00| false| 20.71|\n|2017-11-01T00:07:00.000+08:00| false| 21.45|\n+-----------------------------+------------------------+-----------------------------+\nTotal line number = 5\nIt costs 0.342s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br")])]),s("ul",[s("li",[e._v("Example 3: LIMIT clause combined with WHERE clause")])]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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 3\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is "status" and "temperature". The SQL statement requires rows 3 to 4 of the status and temperature sensor values between the time point of "2017-11-01T00:05:00.000" and "2017-11-01T00:12:00.000" (with the first row numbered as row 0).')]),e._v(" "),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+------------------------+-----------------------------+\n| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|\n+-----------------------------+------------------------+-----------------------------+\n|2017-11-01T00:03:00.000+08:00| false| 20.18|\n|2017-11-01T00:04:00.000+08:00| false| 21.13|\n|2017-11-01T00:05:00.000+08:00| false| 22.72|\n|2017-11-01T00:06:00.000+08:00| false| 20.71|\n|2017-11-01T00:07:00.000+08:00| false| 21.45|\n+-----------------------------+------------------------+-----------------------------+\nTotal line number = 5\nIt costs 0.000s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br")])]),s("ul",[s("li",[e._v("Example 4: LIMIT clause combined with GROUP BY clause")])]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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 5 offset 3\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("The SQL statement clause requires rows 3 to 7 of the query result be returned (with the first row numbered as row 0).")]),e._v(" "),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-------------------------------+----------------------------------------+\n| Time|count(root.ln.wf01.wt01.status)|max_value(root.ln.wf01.wt01.temperature)|\n+-----------------------------+-------------------------------+----------------------------------------+\n|2017-11-04T00:00:00.000+08:00| 1440| 26.0|\n|2017-11-05T00:00:00.000+08:00| 1440| 26.0|\n|2017-11-06T00:00:00.000+08:00| 1440| 25.99|\n|2017-11-07T00:00:00.000+08:00| 1380| 26.0|\n+-----------------------------+-------------------------------+----------------------------------------+\nTotal line number = 4\nIt costs 0.016s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br")])]),s("p",[e._v("It is worth noting that because the current FILL clause can only fill in the missing value of timeseries at a certain time point, that is to say, the execution result of FILL clause is exactly one line, so LIMIT and OFFSET are not expected to be used in combination with FILL clause, otherwise errors will be prompted. For example, executing the following SQL statement:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float[previous, 1m]) limit 10\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The SQL statement will not be executed and the corresponding error prompt is given as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("Msg: 401: line 1:107 mismatched input 'limit' expecting {<EOF>, SLIMIT, SOFFSET, GROUP, DISABLE, ALIGN}\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("h4",{attrs:{id:"column-control-over-query-results"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#column-control-over-query-results"}},[e._v("#")]),e._v(" Column Control over Query Results")]),e._v(" "),s("p",[e._v("By using SLIMIT and SOFFSET clauses, users can control the query results in a column-related manner. We will demonstrate how to use SLIMIT and SOFFSET clauses through the following examples.")]),e._v(" "),s("ul",[s("li",[e._v("Example 1: basic SLIMIT clause")])]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select * from root.ln.wf01.wt01 where time > 2017-11-01T00:05:00.000 and time < 2017-11-01T00:12:00.000 slimit 1\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is the first column under this device, i.e., the power supply status. The SQL statement requires the status sensor values between the time point of "2017-11-01T00:05:00.000" and "2017-11-01T00:12:00.000" be selected.')]),e._v(" "),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-----------------------------+\n| Time|root.ln.wf01.wt01.temperature|\n+-----------------------------+-----------------------------+\n|2017-11-01T00:06:00.000+08:00| 20.71|\n|2017-11-01T00:07:00.000+08:00| 21.45|\n|2017-11-01T00:08:00.000+08:00| 22.58|\n|2017-11-01T00:09:00.000+08:00| 20.98|\n|2017-11-01T00:10:00.000+08:00| 25.52|\n|2017-11-01T00:11:00.000+08:00| 22.91|\n+-----------------------------+-----------------------------+\nTotal line number = 6\nIt costs 0.000s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br")])]),s("ul",[s("li",[e._v("Example 2: SLIMIT clause with SOFFSET")])]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v('The selected device is ln group wf01 plant wt01 device; the selected timeseries is the second column under this device, i.e., the temperature. The SQL statement requires the temperature sensor values between the time point of "2017-11-01T00:05:00.000" and "2017-11-01T00:12:00.000" be selected.')]),e._v(" "),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+------------------------+\n| Time|root.ln.wf01.wt01.status|\n+-----------------------------+------------------------+\n|2017-11-01T00:06:00.000+08:00| false|\n|2017-11-01T00:07:00.000+08:00| false|\n|2017-11-01T00:08:00.000+08:00| false|\n|2017-11-01T00:09:00.000+08:00| false|\n|2017-11-01T00:10:00.000+08:00| true|\n|2017-11-01T00:11:00.000+08:00| false|\n+-----------------------------+------------------------+\nTotal line number = 6\nIt costs 0.003s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br")])]),s("ul",[s("li",[e._v("Example 3: SLIMIT clause combined with GROUP BY clause")])]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-----------------------------------+\n| Time|max_value(root.ln.wf01.wt01.status)|\n+-----------------------------+-----------------------------------+\n|2017-11-01T00:00:00.000+08:00| true|\n|2017-11-02T00:00:00.000+08:00| true|\n|2017-11-03T00:00:00.000+08:00| true|\n|2017-11-04T00:00:00.000+08:00| true|\n|2017-11-05T00:00:00.000+08:00| true|\n|2017-11-06T00:00:00.000+08:00| true|\n|2017-11-07T00:00:00.000+08:00| true|\n+-----------------------------+-----------------------------------+\nTotal line number = 7\nIt costs 0.000s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br")])]),s("ul",[s("li",[e._v("Example 4: SLIMIT clause combined with FILL clause")])]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select * from root.sgcc.wf03.wt01 where time = 2017-11-01T16:35:00 fill(float[previous, 1m]) slimit 1 soffset 1\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("The selected device is ln group wf01 plant wt01 device; the selected timeseries is the second column under this device, i.e., the temperature.")]),e._v(" "),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+--------------------------+\n| Time|root.sgcc.wf03.wt01.status|\n+-----------------------------+--------------------------+\n|2017-11-01T16:35:00.000+08:00| true|\n+-----------------------------+--------------------------+\nTotal line number = 1\nIt costs 0.007s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br")])]),s("h4",{attrs:{id:"row-and-column-control-over-query-results-2"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#row-and-column-control-over-query-results-2"}},[e._v("#")]),e._v(" Row and Column Control over Query Results")]),e._v(" "),s("p",[e._v("In addition to row or column control over query results, IoTDB allows users to control both rows and columns of query results. Here is a complete example with both LIMIT clauses and SLIMIT clauses.")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select * from root.ln.wf01.wt01 limit 10 offset 100 slimit 2 soffset 0\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("which means:")]),e._v(" "),s("p",[e._v("The selected device is ln group wf01 plant wt01 device; the selected timeseries is columns 0 to 1 under this device (with the first column numbered as column 0). The SQL statement clause requires rows 100 to 109 of the query result be returned (with the first row numbered as row 0).")]),e._v(" "),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-----------------------------+------------------------+\n| Time|root.ln.wf01.wt01.temperature|root.ln.wf01.wt01.status|\n+-----------------------------+-----------------------------+------------------------+\n|2017-11-01T01:40:00.000+08:00| 21.19| false|\n|2017-11-01T01:41:00.000+08:00| 22.79| false|\n|2017-11-01T01:42:00.000+08:00| 22.98| false|\n|2017-11-01T01:43:00.000+08:00| 21.52| false|\n|2017-11-01T01:44:00.000+08:00| 23.45| true|\n|2017-11-01T01:45:00.000+08:00| 24.06| true|\n|2017-11-01T01:46:00.000+08:00| 22.6| false|\n|2017-11-01T01:47:00.000+08:00| 23.78| true|\n|2017-11-01T01:48:00.000+08:00| 24.72| true|\n|2017-11-01T01:49:00.000+08:00| 24.68| true|\n+-----------------------------+-----------------------------+------------------------+\nTotal line number = 10\nIt costs 0.009s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br"),s("span",{staticClass:"line-number"},[e._v("13")]),s("br"),s("span",{staticClass:"line-number"},[e._v("14")]),s("br"),s("span",{staticClass:"line-number"},[e._v("15")]),s("br"),s("span",{staticClass:"line-number"},[e._v("16")]),s("br")])]),s("h3",{attrs:{id:"use-alias"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#use-alias"}},[e._v("#")]),e._v(" Use Alias")]),e._v(" "),s("p",[e._v("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 "),s("code",[e._v("AS")]),e._v(" function provided by IoTDB, assign an alias to time series selected in query.")]),e._v(" "),s("p",[e._v("For example:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select s1 as temperature, s2 as speed from root.ln.wf01.wt01;\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The result set is:")]),e._v(" "),s("table",[s("thead",[s("tr",[s("th",[e._v("Time")]),e._v(" "),s("th",[e._v("temperature")]),e._v(" "),s("th",[e._v("speed")])])]),e._v(" "),s("tbody",[s("tr",[s("td",[e._v("...")]),e._v(" "),s("td",[e._v("...")]),e._v(" "),s("td",[e._v("...")])])])]),e._v(" "),s("h4",{attrs:{id:"other-resultset-format"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#other-resultset-format"}},[e._v("#")]),e._v(" Other ResultSet Format")]),e._v(" "),s("p",[e._v("In addition, IoTDB supports two other results set format: 'align by device' and 'disable align'.")]),e._v(" "),s("p",[e._v("The 'align by device' indicates that the deviceId is considered as a column. Therefore, there are totally limited columns in the dataset.")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select * from root.ln.* where time <= 2017-11-01T00:01:00 align by device\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The result shows below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+-----------------+-----------+------+--------+\n| Time| Device|temperature|status|hardware|\n+-----------------------------+-----------------+-----------+------+--------+\n|2017-11-01T00:00:00.000+08:00|root.ln.wf01.wt01| 25.96| true| null|\n|2017-11-01T00:01:00.000+08:00|root.ln.wf01.wt01| 24.36| true| null|\n|1970-01-01T08:00:00.001+08:00|root.ln.wf02.wt02| null| true| v1|\n|1970-01-01T08:00:00.002+08:00|root.ln.wf02.wt02| null| false| v2|\n|2017-11-01T00:00:00.000+08:00|root.ln.wf02.wt02| null| true| v2|\n|2017-11-01T00:01:00.000+08:00|root.ln.wf02.wt02| null| true| v2|\n+-----------------------------+-----------------+-----------+------+--------+\nTotal line number = 6\nIt costs 0.012s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br")])]),s("p",[e._v("For more syntax description, please read "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("SQL Reference")]),e._v(".")],1),e._v(" "),s("p",[e._v("The 'disable align' indicates that there are 2 columns for each time series in the result set. Disable Align Clause can only be used at the end of a query statement. Disable Align Clause cannot be used with Aggregation, Fill Statements, Group By or Group By Device Statements, but can with Limit Statements. The display principle of the result table is that only when the column (or row) has existing data will the column (or row) be shown, with nonexistent cells being empty.")]),e._v(" "),s("p",[e._v("The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("select * from root.ln.* where time <= 2017-11-01T00:01:00 disable align\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The result shows below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+\n| Time|root.ln.wf02.wt02.hardware| Time|root.ln.wf02.wt02.status| Time|root.ln.wf01.wt01.temperature| Time|root.ln.wf01.wt01.status|\n+-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+\n|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|\n|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|\n|2017-11-01T00:00:00.000+08:00| v2|2017-11-01T00:00:00.000+08:00| true| null| null| null| null|\n|2017-11-01T00:01:00.000+08:00| v2|2017-11-01T00:01:00.000+08:00| true| null| null| null| null|\n+-----------------------------+--------------------------+-----------------------------+------------------------+-----------------------------+-----------------------------+-----------------------------+------------------------+\nTotal line number = 4\nIt costs 0.018s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br")])]),s("p",[e._v("For more syntax description, please read "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("SQL Reference")]),e._v(".")],1),e._v(" "),s("h4",{attrs:{id:"error-handling"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#error-handling"}},[e._v("#")]),e._v(" Error Handling")]),e._v(" "),s("p",[e._v("If the parameter N/SN of LIMIT/SLIMIT exceeds the size of the result set, IoTDB returns all the results as expected. For example, the query result of the original SQL statement consists of six rows, and we select the first 100 rows through the LIMIT clause:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+-----------------------------+------------------------+-----------------------------+\n| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|\n+-----------------------------+------------------------+-----------------------------+\n|2017-11-01T00:06:00.000+08:00| false| 20.71|\n|2017-11-01T00:07:00.000+08:00| false| 21.45|\n|2017-11-01T00:08:00.000+08:00| false| 22.58|\n|2017-11-01T00:09:00.000+08:00| false| 20.98|\n|2017-11-01T00:10:00.000+08:00| true| 25.52|\n|2017-11-01T00:11:00.000+08:00| false| 22.91|\n+-----------------------------+------------------------+-----------------------------+\nTotal line number = 6\nIt costs 0.005s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br"),s("span",{staticClass:"line-number"},[e._v("8")]),s("br"),s("span",{staticClass:"line-number"},[e._v("9")]),s("br"),s("span",{staticClass:"line-number"},[e._v("10")]),s("br"),s("span",{staticClass:"line-number"},[e._v("11")]),s("br"),s("span",{staticClass:"line-number"},[e._v("12")]),s("br")])]),s("p",[e._v("If the parameter N/SN of LIMIT/SLIMIT clause exceeds the allowable maximum value (N/SN is of type int32), the system prompts errors. For example, executing the following SQL statement:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The SQL statement will not be executed and the corresponding error prompt is given as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("Msg: 303: check metadata error: Out of range. LIMIT <N>: N should be Int32.\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("If the parameter N/SN of LIMIT/SLIMIT clause is not a positive intege, the system prompts errors. For example, executing the following SQL statement:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The SQL statement will not be executed and the corresponding error prompt is given as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("Msg: 401: line 1:129 mismatched input '.' expecting {<EOF>, SLIMIT, OFFSET, SOFFSET, GROUP, DISABLE, ALIGN}\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("If the parameter OFFSET of LIMIT clause exceeds the size of the result set, IoTDB will return an empty result set. For example, executing the following SQL statement:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The result is shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("+----+------------------------+-----------------------------+\n|Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|\n+----+------------------------+-----------------------------+\n+----+------------------------+-----------------------------+\nEmpty set.\nIt costs 0.005s\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br")])]),s("p",[e._v("If the parameter SOFFSET of SLIMIT clause is not smaller than the number of available timeseries, the system prompts errors. For example, executing the following SQL statement:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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 2\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The SQL statement will not be executed and the corresponding error prompt is given as follows:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("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.\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("h2",{attrs:{id:"delete"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#delete"}},[e._v("#")]),e._v(" DELETE")]),e._v(" "),s("p",[e._v("Users can delete data that meet the deletion condition in the specified timeseries by using the "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Operation Manual/SQL Reference.html"}},[e._v("DELETE statement")]),e._v(". When deleting data, users can select one or more timeseries paths, prefix paths, or paths with star to delete data within a certain time interval.")],1),e._v(" "),s("p",[e._v("In a JAVA programming environment, you can use the "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Client/Programming - JDBC.html"}},[e._v("Java JDBC")]),e._v(" to execute single or batch UPDATE statements.")],1),e._v(" "),s("h3",{attrs:{id:"delete-single-timeseries"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#delete-single-timeseries"}},[e._v("#")]),e._v(" Delete Single Timeseries")]),e._v(" "),s("p",[e._v("Taking ln Group as an example, there exists such a usage scenario:")]),e._v(" "),s("p",[e._v("The wf02 plant's wt02 device has many segments of errors in its power supply status before 2017-11-01 16:26:00, and the data cannot be analyzed correctly. The erroneous data affected the correlation analysis with other devices. At this point, the data before this time point needs to be deleted. The SQL statement for this operation is")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("delete from root.ln.wf02.wt02.status where time<=2017-11-01T16:26:00;\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("In case we hope to merely delete the data before 2017-11-01 16:26:00 in the year of 2017, The SQL statement is:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("delete from root.ln.wf02.wt02.status where time>=2017-01-01T00:00:00 and time<=2017-11-01T16:26:00;\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("IoTDB supports to delete a range of timeseries points. Users can write SQL expressions as follows to specify the delete interval:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("delete from root.ln.wf02.wt02.status where time < 10\ndelete from root.ln.wf02.wt02.status where time <= 10\ndelete from root.ln.wf02.wt02.status where time < 20 and time > 10\ndelete from root.ln.wf02.wt02.status where time <= 20 and time >= 10\ndelete from root.ln.wf02.wt02.status where time > 20\ndelete from root.ln.wf02.wt02.status where time >= 20\ndelete from root.ln.wf02.wt02.status where time = 20\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br"),s("span",{staticClass:"line-number"},[e._v("4")]),s("br"),s("span",{staticClass:"line-number"},[e._v("5")]),s("br"),s("span",{staticClass:"line-number"},[e._v("6")]),s("br"),s("span",{staticClass:"line-number"},[e._v("7")]),s("br")])]),s("p",[e._v('Please pay attention that multiple intervals connected by "OR" expression are not supported in delete statement:')]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("delete from root.ln.wf02.wt02.status where time > 4 or time < 0\nMsg: 303: Check metadata error: For delete statement, where clause can only contain atomic\nexpressions like : time > XXX, time <= XXX, or two atomic expressions connected by 'AND'\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br"),s("span",{staticClass:"line-number"},[e._v("3")]),s("br")])]),s("p",[e._v('If no "where" clause specified in a delete statement, all the data in a timeseries will be deleted.')]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("delete from root.ln.wf02.status\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("h3",{attrs:{id:"delete-multiple-timeseries"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#delete-multiple-timeseries"}},[e._v("#")]),e._v(" Delete Multiple Timeseries")]),e._v(" "),s("p",[e._v("If both the power supply status and hardware version of the ln group wf02 plant wt02 device before 2017-11-01 16:26:00 need to be deleted, "),s("RouterLink",{attrs:{to:"/UserGuide/Master/Concept/Data Model and Terminology.html"}},[e._v("the prefix path with broader meaning or the path with star")]),e._v(" can be used to delete the data. The SQL statement for this operation is:")],1),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("delete from root.ln.wf02.wt02 where time <= 2017-11-01T16:26:00;\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("or")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("delete from root.ln.wf02.wt02.* where time <= 2017-11-01T16:26:00;\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("It should be noted that when the deleted path does not exist, IoTDB will give the corresponding error prompt as shown below:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("IoTDB> delete from root.ln.wf03.wt02.status where time < now()\nMsg: TimeSeries does not exist and its data cannot be deleted\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br"),s("span",{staticClass:"line-number"},[e._v("2")]),s("br")])]),s("h2",{attrs:{id:"delete-time-partition-experimental"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#delete-time-partition-experimental"}},[e._v("#")]),e._v(" Delete Time Partition (experimental)")]),e._v(" "),s("p",[e._v("You may delete all data in a time partition of a storage group using the following grammar:")]),e._v(" "),s("div",{staticClass:"language- line-numbers-mode"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("DELETE PARTITION root.ln 0,1,2\n")])]),e._v(" "),s("div",{staticClass:"line-numbers-wrapper"},[s("span",{staticClass:"line-number"},[e._v("1")]),s("br")])]),s("p",[e._v("The "),s("code",[e._v("0,1,2")]),e._v(" above is the id of the partition that is to be deleted, you can find it from the IoTDB\ndata folders or convert a timestamp manually to an id using "),s("code",[e._v("timestamp / partitionInterval")]),e._v(" (flooring), and the "),s("code",[e._v("partitionInterval")]),e._v(" should be in your config (if time-partitioning is\nsupported in your version).")]),e._v(" "),s("p",[e._v("Please notice that this function is experimental and mainly for development, please use it with care.")])],1)}),[],!1,null,null,null);t.default=n.exports}}]);