blob: 97cef5feac8664ad172407d2962c5326970e4ea0 [file] [log] [blame]
import{_ as i,C as l,O as p,P as c,ah as r,Q as s,U as n,ai as a,ae as t,aW as o}from"./framework-e4340ccd.js";const u={},d=o(`<h1 id="overview" tabindex="-1"><a class="header-anchor" href="#overview" aria-hidden="true">#</a> Overview</h1><h2 id="syntax-definition" tabindex="-1"><a class="header-anchor" href="#syntax-definition" aria-hidden="true">#</a> Syntax Definition</h2><p>In IoTDB, <code>SELECT</code> statement is used to retrieve data from one or more selected time series. Here is the syntax definition of <code>SELECT</code> statement:</p><div class="language-sql line-numbers-mode" data-ext="sql"><pre class="language-sql"><code><span class="token keyword">SELECT</span> <span class="token punctuation">[</span><span class="token keyword">LAST</span><span class="token punctuation">]</span> selectExpr <span class="token punctuation">[</span><span class="token punctuation">,</span> selectExpr<span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">[</span><span class="token keyword">INTO</span> intoItem <span class="token punctuation">[</span><span class="token punctuation">,</span> intoItem<span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">]</span>
<span class="token keyword">FROM</span> prefixPath <span class="token punctuation">[</span><span class="token punctuation">,</span> prefixPath<span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">[</span><span class="token keyword">WHERE</span> whereCondition<span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">GROUP</span> <span class="token keyword">BY</span> {
<span class="token punctuation">(</span><span class="token punctuation">[</span>startTime<span class="token punctuation">,</span> endTime<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">interval</span> <span class="token punctuation">[</span><span class="token punctuation">,</span> slidingStep<span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token operator">|</span>
<span class="token keyword">LEVEL</span> <span class="token operator">=</span> levelNum <span class="token punctuation">[</span><span class="token punctuation">,</span> levelNum<span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token operator">|</span>
TAGS<span class="token punctuation">(</span>tagKey <span class="token punctuation">[</span><span class="token punctuation">,</span> tagKey<span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">)</span>
VARIATION<span class="token punctuation">(</span>expression<span class="token punctuation">[</span><span class="token punctuation">,</span>delta<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">,</span>ignoreNull<span class="token operator">=</span><span class="token boolean">true</span><span class="token operator">/</span><span class="token boolean">false</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">|</span>
SERIES<span class="token punctuation">(</span>expression<span class="token punctuation">,</span><span class="token punctuation">[</span>keep<span class="token operator">&gt;</span><span class="token operator">/</span><span class="token operator">&gt;=</span><span class="token operator">/</span><span class="token operator">=</span><span class="token operator">/</span><span class="token operator">&lt;</span><span class="token operator">/</span><span class="token operator">&lt;=</span><span class="token punctuation">]</span>threshold<span class="token punctuation">[</span><span class="token punctuation">,</span>ignoreNull<span class="token operator">=</span><span class="token boolean">true</span><span class="token operator">/</span><span class="token boolean">false</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">|</span>
<span class="token keyword">SESSION</span><span class="token punctuation">(</span>timeInterval<span class="token punctuation">)</span>
}<span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">HAVING</span> havingCondition<span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">ORDER</span> <span class="token keyword">BY</span> sortKey {<span class="token keyword">ASC</span> <span class="token operator">|</span> <span class="token keyword">DESC</span>}<span class="token punctuation">]</span>
<span class="token punctuation">[</span>FILL <span class="token punctuation">(</span>{PREVIOUS <span class="token operator">|</span> LINEAR <span class="token operator">|</span> constant}<span class="token punctuation">)</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span>SLIMIT seriesLimit<span class="token punctuation">]</span> <span class="token punctuation">[</span>SOFFSET seriesOffset<span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">LIMIT</span> rowLimit<span class="token punctuation">]</span> <span class="token punctuation">[</span><span class="token keyword">OFFSET</span> rowOffset<span class="token punctuation">]</span>
<span class="token punctuation">[</span>ALIGN <span class="token keyword">BY</span> {<span class="token keyword">TIME</span> <span class="token operator">|</span> DEVICE}<span class="token punctuation">]</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="syntax-description" tabindex="-1"><a class="header-anchor" href="#syntax-description" aria-hidden="true">#</a> Syntax Description</h2><h3 id="select-clause" tabindex="-1"><a class="header-anchor" href="#select-clause" aria-hidden="true">#</a> <code>SELECT</code> clause</h3>`,6),m=s("li",null,[n("The "),s("code",null,"SELECT"),n(" clause specifies the output of the query, consisting of several "),s("code",null,"selectExpr"),n(".")],-1),k=s("li",null,[n("Each "),s("code",null,"selectExpr"),n(" defines one or more columns in the query result, which is an expression consisting of time series path suffixes, constants, functions, and operators.")],-1),h=s("li",null,[n("Supports using "),s("code",null,"AS"),n(" to specify aliases for columns in the query result set.")],-1),v=s("code",null,"LAST",-1),g=s("code",null,"SELECT",-1),f=s("h3",{id:"into-clause",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#into-clause","aria-hidden":"true"},"#"),n(),s("code",null,"INTO"),n(" clause")],-1),b=s("li",null,[s("code",null,"SELECT INTO"),n(" is used to write query results into a series of specified time series. The "),s("code",null,"INTO"),n(" clause specifies the target time series to which query results are written.")],-1),y=o('<h3 id="from-clause" tabindex="-1"><a class="header-anchor" href="#from-clause" aria-hidden="true">#</a> <code>FROM</code> clause</h3><ul><li>The <code>FROM</code> clause contains the path prefix of one or more time series to be queried, and wildcards are supported.</li><li>When executing a query, the path prefix in the <code>FROM</code> clause and the suffix in the <code>SELECT</code> clause will be concatenated to obtain a complete query target time series.</li></ul><h3 id="where-clause" tabindex="-1"><a class="header-anchor" href="#where-clause" aria-hidden="true">#</a> <code>WHERE</code> clause</h3>',3),w=o("<li>The <code>WHERE</code> clause specifies the filtering conditions for data rows, consisting of a <code>whereCondition</code>.</li><li><code>whereCondition</code> is a logical expression that evaluates to true for each row to be selected. If there is no <code>WHERE</code> clause, all rows will be selected.</li><li>In <code>whereCondition</code>, any IOTDB-supported functions and operators can be used except aggregate functions.</li>",3),T=s("h3",{id:"group-by-clause",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#group-by-clause","aria-hidden":"true"},"#"),n(),s("code",null,"GROUP BY"),n(" clause")],-1),x=o("<li>The <code>GROUP BY</code> clause specifies how the time series are aggregated by segment or group.</li><li>Segmented aggregation refers to segmenting data in the row direction according to the time dimension, aiming at the time relationship between different data points in the same time series, and obtaining an aggregated value for each segment. Currently only <strong>segmentation by time interval</strong>、<strong>group by variation</strong>、<strong>group by series</strong> and <strong>group by session</strong> is supported, and more segmentation methods will be supported in the future.</li><li>Group aggregation refers to grouping the potential business attributes of time series for different time series. Each group contains several time series, and each group gets an aggregated value. Support <strong>group by path level</strong> and <strong>group by tag</strong> two grouping methods.</li><li>Segment aggregation and group aggregation can be mixed.</li>",4),S=s("h3",{id:"having-clause",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#having-clause","aria-hidden":"true"},"#"),n(),s("code",null,"HAVING"),n(" clause")],-1),q=o("<li>The <code>HAVING</code> clause specifies the filter conditions for the aggregation results, consisting of a <code>havingCondition</code>.</li><li><code>havingCondition</code> is a logical expression that evaluates to true for the aggregation results to be selected. If there is no <code>HAVING</code> clause, all aggregated results will be selected.</li><li><code>HAVING</code> is to be used with aggregate functions and the <code>GROUP BY</code> clause.</li>",3),I=s("h3",{id:"order-by-clause",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#order-by-clause","aria-hidden":"true"},"#"),n(),s("code",null,"ORDER BY"),n(" clause")],-1),_=s("li",null,[n("The "),s("code",null,"ORDER BY"),n(" clause is used to specify how the result set is sorted.")],-1),L=s("li",null,[n("In ALIGN BY TIME mode: By default, they are sorted in ascending order of timestamp size, and "),s("code",null,"ORDER BY TIME DESC"),n(" can be used to specify that the result set is sorted in descending order of timestamp.")],-1),E=s("li",null,[n("In ALIGN BY DEVICE mode: arrange according to the device first, and sort each device in ascending order according to the timestamp. The ordering and priority can be adjusted by "),s("code",null,"ORDER BY"),n(" clause.")],-1),A=s("h3",{id:"fill-clause",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#fill-clause","aria-hidden":"true"},"#"),n(),s("code",null,"FILL"),n(" clause")],-1),D=s("li",null,[n("The "),s("code",null,"FILL"),n(" clause is used to specify the filling mode in the case of missing data, allowing users to fill in empty values ​​for the result set of any query according to a specific method.")],-1),Q=s("h3",{id:"slimit-and-soffset-clauses",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#slimit-and-soffset-clauses","aria-hidden":"true"},"#"),n(),s("code",null,"SLIMIT"),n(" and "),s("code",null,"SOFFSET"),n(" clauses")],-1),C=s("li",null,[s("code",null,"SLIMIT"),n(" specifies the number of columns of the query result, and "),s("code",null,"SOFFSET"),n(" specifies the starting column position of the query result display. "),s("code",null,"SLIMIT"),n(" and "),s("code",null,"SOFFSET"),n(" are only used to control value columns and have no effect on time and device columns.")],-1),O=s("h3",{id:"limit-and-offset-clauses",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#limit-and-offset-clauses","aria-hidden":"true"},"#"),n(),s("code",null,"LIMIT"),n(" and "),s("code",null,"OFFSET"),n(" clauses")],-1),F=s("li",null,[s("code",null,"LIMIT"),n(" specifies the number of rows of the query result, and "),s("code",null,"OFFSET"),n(" specifies the starting row position of the query result display.")],-1),B=s("h3",{id:"align-by-clause",tabindex:"-1"},[s("a",{class:"header-anchor",href:"#align-by-clause","aria-hidden":"true"},"#"),n(),s("code",null,"ALIGN BY"),n(" clause")],-1),R=s("li",null,[n("The query result set is "),s("strong",null,"ALIGN BY TIME"),n(" by default, including a time column and several value columns, and the timestamps of each column of data in each row are the same.")],-1),V=s("li",null,[n("It also supports "),s("strong",null,"ALIGN BY DEVICE"),n(". The query result set contains a time column, a device column, and several value columns.")],-1),G=o(`<h2 id="basic-examples" tabindex="-1"><a class="header-anchor" href="#basic-examples" aria-hidden="true">#</a> Basic Examples</h2><h3 id="select-a-column-of-data-based-on-a-time-interval" tabindex="-1"><a class="header-anchor" href="#select-a-column-of-data-based-on-a-time-interval" aria-hidden="true">#</a> Select a Column of Data Based on a Time Interval</h3><p>The SQL statement is:</p><div class="language-sql line-numbers-mode" data-ext="sql"><pre class="language-sql"><code><span class="token keyword">select</span> temperature <span class="token keyword">from</span> root<span class="token punctuation">.</span>ln<span class="token punctuation">.</span>wf01<span class="token punctuation">.</span>wt01 <span class="token keyword">where</span> <span class="token keyword">time</span> <span class="token operator">&lt;</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">08</span>:<span class="token number">00.000</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>which means:</p><p>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 &quot;2017-11-01T00:08:00.000&quot; be selected.</p><p>The execution result of this SQL statement is as follows:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>+-----------------------------+-----------------------------+
| Time|root.ln.wf01.wt01.temperature|
+-----------------------------+-----------------------------+
|2017-11-01T00:00:00.000+08:00| 25.96|
|2017-11-01T00:01:00.000+08:00| 24.36|
|2017-11-01T00:02:00.000+08:00| 20.09|
|2017-11-01T00:03:00.000+08:00| 20.18|
|2017-11-01T00:04:00.000+08:00| 21.13|
|2017-11-01T00:05:00.000+08:00| 22.72|
|2017-11-01T00:06:00.000+08:00| 20.71|
|2017-11-01T00:07:00.000+08:00| 21.45|
+-----------------------------+-----------------------------+
Total line number = 8
It costs 0.026s
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="select-multiple-columns-of-data-based-on-a-time-interval" tabindex="-1"><a class="header-anchor" href="#select-multiple-columns-of-data-based-on-a-time-interval" aria-hidden="true">#</a> Select Multiple Columns of Data Based on a Time Interval</h3><p>The SQL statement is:</p><div class="language-sql line-numbers-mode" data-ext="sql"><pre class="language-sql"><code><span class="token keyword">select</span> <span class="token keyword">status</span><span class="token punctuation">,</span> temperature <span class="token keyword">from</span> root<span class="token punctuation">.</span>ln<span class="token punctuation">.</span>wf01<span class="token punctuation">.</span>wt01 <span class="token keyword">where</span> <span class="token keyword">time</span> <span class="token operator">&gt;</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">05</span>:<span class="token number">00.000</span> <span class="token operator">and</span> <span class="token keyword">time</span> <span class="token operator">&lt;</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">12</span>:<span class="token number">00.000</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>which means:</p><p>The selected device is ln group wf01 plant wt01 device; the selected timeseries is &quot;status&quot; and &quot;temperature&quot;. The SQL statement requires that the status and temperature sensor values between the time point of &quot;2017-11-01T00:05:00.000&quot; and &quot;2017-11-01T00:12:00.000&quot; be selected.</p><p>The execution result of this SQL statement is as follows:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>+-----------------------------+------------------------+-----------------------------+
| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
+-----------------------------+------------------------+-----------------------------+
|2017-11-01T00:06:00.000+08:00| false| 20.71|
|2017-11-01T00:07:00.000+08:00| false| 21.45|
|2017-11-01T00:08:00.000+08:00| false| 22.58|
|2017-11-01T00:09:00.000+08:00| false| 20.98|
|2017-11-01T00:10:00.000+08:00| true| 25.52|
|2017-11-01T00:11:00.000+08:00| false| 22.91|
+-----------------------------+------------------------+-----------------------------+
Total line number = 6
It costs 0.018s
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="select-multiple-columns-of-data-for-the-same-device-according-to-multiple-time-intervals" tabindex="-1"><a class="header-anchor" href="#select-multiple-columns-of-data-for-the-same-device-according-to-multiple-time-intervals" aria-hidden="true">#</a> Select Multiple Columns of Data for the Same Device According to Multiple Time Intervals</h3><p>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:</p><div class="language-sql line-numbers-mode" data-ext="sql"><pre class="language-sql"><code><span class="token keyword">select</span> <span class="token keyword">status</span><span class="token punctuation">,</span>temperature <span class="token keyword">from</span> root<span class="token punctuation">.</span>ln<span class="token punctuation">.</span>wf01<span class="token punctuation">.</span>wt01 <span class="token keyword">where</span> <span class="token punctuation">(</span><span class="token keyword">time</span> <span class="token operator">&gt;</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">05</span>:<span class="token number">00.000</span> <span class="token operator">and</span> <span class="token keyword">time</span> <span class="token operator">&lt;</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">12</span>:<span class="token number">00.000</span><span class="token punctuation">)</span> <span class="token operator">or</span> <span class="token punctuation">(</span><span class="token keyword">time</span> <span class="token operator">&gt;=</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T16:<span class="token number">35</span>:<span class="token number">00.000</span> <span class="token operator">and</span> <span class="token keyword">time</span> <span class="token operator">&lt;=</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T16:<span class="token number">37</span>:<span class="token number">00.000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>which means:</p><p>The selected device is ln group wf01 plant wt01 device; the selected timeseries is &quot;status&quot; and &quot;temperature&quot;; the statement specifies two different time intervals, namely &quot;2017-11-01T00:05:00.000 to 2017-11-01T00:12:00.000&quot; and &quot;2017-11-01T16:35:00.000 to 2017-11-01T16:37:00.000&quot;. The SQL statement requires that the values of selected timeseries satisfying any time interval be selected.</p><p>The execution result of this SQL statement is as follows:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>+-----------------------------+------------------------+-----------------------------+
| Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
+-----------------------------+------------------------+-----------------------------+
|2017-11-01T00:06:00.000+08:00| false| 20.71|
|2017-11-01T00:07:00.000+08:00| false| 21.45|
|2017-11-01T00:08:00.000+08:00| false| 22.58|
|2017-11-01T00:09:00.000+08:00| false| 20.98|
|2017-11-01T00:10:00.000+08:00| true| 25.52|
|2017-11-01T00:11:00.000+08:00| false| 22.91|
|2017-11-01T16:35:00.000+08:00| true| 23.44|
|2017-11-01T16:36:00.000+08:00| false| 21.98|
|2017-11-01T16:37:00.000+08:00| false| 21.93|
+-----------------------------+------------------------+-----------------------------+
Total line number = 9
It costs 0.018s
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="choose-multiple-columns-of-data-for-different-devices-according-to-multiple-time-intervals" tabindex="-1"><a class="header-anchor" href="#choose-multiple-columns-of-data-for-different-devices-according-to-multiple-time-intervals" aria-hidden="true">#</a> Choose Multiple Columns of Data for Different Devices According to Multiple Time Intervals</h3><p>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:</p><div class="language-sql line-numbers-mode" data-ext="sql"><pre class="language-sql"><code><span class="token keyword">select</span> wf01<span class="token punctuation">.</span>wt01<span class="token punctuation">.</span><span class="token keyword">status</span><span class="token punctuation">,</span>wf02<span class="token punctuation">.</span>wt02<span class="token punctuation">.</span>hardware <span class="token keyword">from</span> root<span class="token punctuation">.</span>ln <span class="token keyword">where</span> <span class="token punctuation">(</span><span class="token keyword">time</span> <span class="token operator">&gt;</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">05</span>:<span class="token number">00.000</span> <span class="token operator">and</span> <span class="token keyword">time</span> <span class="token operator">&lt;</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T00:<span class="token number">12</span>:<span class="token number">00.000</span><span class="token punctuation">)</span> <span class="token operator">or</span> <span class="token punctuation">(</span><span class="token keyword">time</span> <span class="token operator">&gt;=</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T16:<span class="token number">35</span>:<span class="token number">00.000</span> <span class="token operator">and</span> <span class="token keyword">time</span> <span class="token operator">&lt;=</span> <span class="token number">2017</span><span class="token operator">-</span><span class="token number">11</span><span class="token operator">-</span><span class="token number">01</span>T16:<span class="token number">37</span>:<span class="token number">00.000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>which means:</p><p>The selected timeseries are &quot;the power supply status of ln group wf01 plant wt01 device&quot; and &quot;the hardware version of ln group wf02 plant wt02 device&quot;; the statement specifies two different time intervals, namely &quot;2017-11-01T00:05:00.000 to 2017-11-01T00:12:00.000&quot; and &quot;2017-11-01T16:35:00.000 to 2017-11-01T16:37:00.000&quot;. The SQL statement requires that the values of selected timeseries satisfying any time interval be selected.</p><p>The execution result of this SQL statement is as follows:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>+-----------------------------+------------------------+--------------------------+
| Time|root.ln.wf01.wt01.status|root.ln.wf02.wt02.hardware|
+-----------------------------+------------------------+--------------------------+
|2017-11-01T00:06:00.000+08:00| false| v1|
|2017-11-01T00:07:00.000+08:00| false| v1|
|2017-11-01T00:08:00.000+08:00| false| v1|
|2017-11-01T00:09:00.000+08:00| false| v1|
|2017-11-01T00:10:00.000+08:00| true| v2|
|2017-11-01T00:11:00.000+08:00| false| v1|
|2017-11-01T16:35:00.000+08:00| true| v2|
|2017-11-01T16:36:00.000+08:00| false| v1|
|2017-11-01T16:37:00.000+08:00| false| v1|
+-----------------------------+------------------------+--------------------------+
Total line number = 9
It costs 0.014s
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="order-by-time-query" tabindex="-1"><a class="header-anchor" href="#order-by-time-query" aria-hidden="true">#</a> Order By Time Query</h3><p>IoTDB supports the &#39;order by time&#39; statement since 0.11, it&#39;s used to display results in descending order by time. For example, the SQL statement is:</p><div class="language-sql line-numbers-mode" data-ext="sql"><pre class="language-sql"><code><span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> root<span class="token punctuation">.</span>ln<span class="token punctuation">.</span><span class="token operator">*</span><span class="token operator">*</span> <span class="token keyword">where</span> <span class="token keyword">time</span> <span class="token operator">&gt;</span> <span class="token number">1</span> <span class="token keyword">order</span> <span class="token keyword">by</span> <span class="token keyword">time</span> <span class="token keyword">desc</span> <span class="token keyword">limit</span> <span class="token number">10</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>The execution result of this SQL statement is as follows:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>+-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+
| Time|root.ln.wf02.wt02.hardware|root.ln.wf02.wt02.status|root.ln.wf01.wt01.temperature|root.ln.wf01.wt01.status|
+-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+
|2017-11-07T23:59:00.000+08:00| v1| false| 21.07| false|
|2017-11-07T23:58:00.000+08:00| v1| false| 22.93| false|
|2017-11-07T23:57:00.000+08:00| v2| true| 24.39| true|
|2017-11-07T23:56:00.000+08:00| v2| true| 24.44| true|
|2017-11-07T23:55:00.000+08:00| v2| true| 25.9| true|
|2017-11-07T23:54:00.000+08:00| v1| false| 22.52| false|
|2017-11-07T23:53:00.000+08:00| v2| true| 24.58| true|
|2017-11-07T23:52:00.000+08:00| v1| false| 20.18| false|
|2017-11-07T23:51:00.000+08:00| v1| false| 22.24| false|
|2017-11-07T23:50:00.000+08:00| v2| true| 23.7| true|
+-----------------------------+--------------------------+------------------------+-----------------------------+------------------------+
Total line number = 10
It costs 0.016s
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="execution-interface" tabindex="-1"><a class="header-anchor" href="#execution-interface" aria-hidden="true">#</a> Execution Interface</h2><p>In IoTDB, there are two ways to execute data query:</p><ul><li>Execute queries using IoTDB-SQL.</li><li>Efficient execution interfaces for common queries, including time-series raw data query, last query, and aggregation query.</li></ul><h3 id="execute-queries-using-iotdb-sql" tabindex="-1"><a class="header-anchor" href="#execute-queries-using-iotdb-sql" aria-hidden="true">#</a> Execute queries using IoTDB-SQL</h3><p>Data query statements can be used in SQL command-line terminals, JDBC, JAVA / C++ / Python / Go and other native APIs, and RESTful APIs.</p>`,39),N=o(`<li><p>Execute query statements in native APIs such as JAVA / C++ / Python / Go. For details, please refer to the relevant documentation in the Application Programming Interface chapter. The interface prototype is as follows:</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token class-name">SessionDataSet</span> <span class="token function">executeQueryStatement</span><span class="token punctuation">(</span><span class="token class-name">String</span> sql<span class="token punctuation">)</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div></li>`,1),P=o(`<h3 id="efficient-execution-interfaces" tabindex="-1"><a class="header-anchor" href="#efficient-execution-interfaces" aria-hidden="true">#</a> Efficient execution interfaces</h3><p>The native APIs provide efficient execution interfaces for commonly used queries, which can save time-consuming operations such as SQL parsing. include:</p><ul><li>Time-series raw data query with time range: <ul><li>The specified query time range is a left-closed right-open interval, including the start time but excluding the end time.</li></ul></li></ul><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token class-name">SessionDataSet</span> <span class="token function">executeRawDataQuery</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> paths<span class="token punctuation">,</span> <span class="token keyword">long</span> startTime<span class="token punctuation">,</span> <span class="token keyword">long</span> endTime<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><ul><li>Last query: <ul><li>Query the last data, whose timestamp is greater than or equal LastTime.</li></ul></li></ul><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token class-name">SessionDataSet</span> <span class="token function">executeLastDataQuery</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> paths<span class="token punctuation">,</span> <span class="token keyword">long</span> <span class="token class-name">LastTime</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><ul><li>Aggregation query: <ul><li>Support specified query time range: The specified query time range is a left-closed right-open interval, including the start time but not the end time.</li><li>Support GROUP BY TIME.</li></ul></li></ul><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token class-name">SessionDataSet</span> <span class="token function">executeAggregationQuery</span><span class="token punctuation">(</span><span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> paths<span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Aggregation</span><span class="token punctuation">&gt;</span></span> aggregations<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">SessionDataSet</span> <span class="token function">executeAggregationQuery</span><span class="token punctuation">(</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> paths<span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Aggregation</span><span class="token punctuation">&gt;</span></span> aggregations<span class="token punctuation">,</span> <span class="token keyword">long</span> startTime<span class="token punctuation">,</span> <span class="token keyword">long</span> endTime<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">SessionDataSet</span> <span class="token function">executeAggregationQuery</span><span class="token punctuation">(</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> paths<span class="token punctuation">,</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Aggregation</span><span class="token punctuation">&gt;</span></span> aggregations<span class="token punctuation">,</span>
<span class="token keyword">long</span> startTime<span class="token punctuation">,</span>
<span class="token keyword">long</span> endTime<span class="token punctuation">,</span>
<span class="token keyword">long</span> interval<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">SessionDataSet</span> <span class="token function">executeAggregationQuery</span><span class="token punctuation">(</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> paths<span class="token punctuation">,</span>
<span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Aggregation</span><span class="token punctuation">&gt;</span></span> aggregations<span class="token punctuation">,</span>
<span class="token keyword">long</span> startTime<span class="token punctuation">,</span>
<span class="token keyword">long</span> endTime<span class="token punctuation">,</span>
<span class="token keyword">long</span> interval<span class="token punctuation">,</span>
<span class="token keyword">long</span> slidingStep<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div>`,8);function U(M,Y){const e=l("RouterLink");return p(),c("div",null,[r(`
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
`),d,s("ul",null,[m,k,h,s("li",null,[n("Use the "),v,n(" keyword in the "),g,n(" clause to specify that the query is the last query. For details and examples, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Last-Query.html"},{default:t(()=>[n("Last Query")]),_:1}),n(".")]),s("li",null,[n("For details and examples, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Select-Expression.html"},{default:t(()=>[n("Select Expression")]),_:1}),n(".")])]),f,s("ul",null,[b,s("li",null,[n("For detailed instructions and examples, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Select-Into.html"},{default:t(()=>[n("SELECT INTO")]),_:1}),n(".")])]),y,s("ul",null,[w,s("li",null,[n("For details and examples, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Where-Condition.html"},{default:t(()=>[n("Where Condition")]),_:1}),n(".")])]),T,s("ul",null,[x,s("li",null,[n("For details and examples, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Group-By.html"},{default:t(()=>[n("Group By Aggregation")]),_:1}),n(".")])]),S,s("ul",null,[q,s("li",null,[n("For details and examples, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Having-Condition.html"},{default:t(()=>[n("Aggregation Result Filtering")]),_:1}),n(".")])]),I,s("ul",null,[_,L,E,s("li",null,[n("For details and examples, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Order-By.html"},{default:t(()=>[n("Order By")]),_:1}),n(".")])]),A,s("ul",null,[D,s("li",null,[n("For details and examples, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Fill.html"},{default:t(()=>[n("Fill Null Value")]),_:1}),n(".")])]),Q,s("ul",null,[C,s("li",null,[n("For details and examples of query result pagination, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Pagination.html"},{default:t(()=>[n("Result Set Pagination")]),_:1}),n(".")])]),O,s("ul",null,[F,s("li",null,[n("For details and examples of query result pagination, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Pagination.html"},{default:t(()=>[n("Result Set Pagination")]),_:1}),n(".")])]),B,s("ul",null,[R,V,s("li",null,[n("For details and examples, see the document "),a(e,{to:"/UserGuide/V1.1.x/Query-Data/Align-By.html"},{default:t(()=>[n("Query Alignment Mode")]),_:1}),n(".")])]),G,s("ul",null,[s("li",null,[s("p",null,[n("Execute the query statement in the SQL command line terminal: start the SQL command line terminal, and directly enter the query statement to execute, see "),a(e,{to:"/UserGuide/V1.1.x/QuickStart/Command-Line-Interface.html"},{default:t(()=>[n("SQL command line terminal")]),_:1}),n(".")])]),s("li",null,[s("p",null,[n("Execute query statements in JDBC, see "),a(e,{to:"/UserGuide/V1.1.x/API/Programming-JDBC.html"},{default:t(()=>[n("JDBC")]),_:1}),n(" for details.")])]),N,s("li",null,[s("p",null,[n("Used in RESTful API, see "),a(e,{to:"/UserGuide/V1.1.x/API/RestServiceV1.html"},{default:t(()=>[n("HTTP API V1")]),_:1}),n(" or "),a(e,{to:"/UserGuide/V1.1.x/API/RestServiceV2.html"},{default:t(()=>[n("HTTP API V2")]),_:1}),n(" for details.")])])]),P])}const j=i(u,[["render",U],["__file","Overview.html.vue"]]);export{j as default};