| <!-- |
| |
| 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. |
| |
| --> |
| |
| # 逻辑运算符 |
| |
| ## 一元逻辑运算符 |
| |
| - 支持运算符:`!` |
| - 输入数据类型:`BOOLEAN`。 |
| - 输出数据类型:`BOOLEAN`。 |
| - 注意:`!`的优先级很高,记得使用括号调整优先级。 |
| |
| ## 二元逻辑运算符 |
| |
| - 支持运算符 |
| - AND:`and`,`&`, `&&` |
| - OR:`or`,`|`,`||` |
| |
| - 输入数据类型:`BOOLEAN`。 |
| |
| - 返回类型 `BOOLEAN`。 |
| |
| - 注意:当某个时间戳下左操作数和右操作数都为`BOOLEAN`类型时,二元逻辑操作才会有输出结果。 |
| |
| **示例:** |
| |
| ```sql |
| select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; |
| ``` |
| |
| 运行结果 |
| ``` |
| IoTDB> select a, b, a > 10, a <= b, !(a <= b), a > 10 && a > b from root.test; |
| +-----------------------------+-----------+-----------+----------------+--------------------------+---------------------------+------------------------------------------------+ |
| | Time|root.test.a|root.test.b|root.test.a > 10|root.test.a <= root.test.b|!root.test.a <= root.test.b|(root.test.a > 10) & (root.test.a > root.test.b)| |
| +-----------------------------+-----------+-----------+----------------+--------------------------+---------------------------+------------------------------------------------+ |
| |1970-01-01T08:00:00.001+08:00| 23| 10.0| true| false| true| true| |
| |1970-01-01T08:00:00.002+08:00| 33| 21.0| true| false| true| true| |
| |1970-01-01T08:00:00.004+08:00| 13| 15.0| true| true| false| false| |
| |1970-01-01T08:00:00.005+08:00| 26| 0.0| true| false| true| true| |
| |1970-01-01T08:00:00.008+08:00| 1| 22.0| false| true| false| false| |
| |1970-01-01T08:00:00.010+08:00| 23| 12.0| true| false| true| true| |
| +-----------------------------+-----------+-----------+----------------+--------------------------+---------------------------+------------------------------------------------+ |
| ``` |
| |