|
@@ -36,6 +36,12 @@ Specifies that all columns from all input streams in the FROM clause should be r
|
|
|
|
|
|
Select all of fields from source stream.
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo;
|
|
|
+```
|
|
|
+
|
|
|
**\* EXCEPT**
|
|
|
|
|
|
Specify one or more fields to be excluded from the result. It allows excluding one or more specific column names from the query result while still including other columns.
|
|
@@ -45,6 +51,12 @@ SELECT * EXCEPT(column_name1, column_name2...)
|
|
|
FROM stream1
|
|
|
```
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * except(a,b) from demo;
|
|
|
+```
|
|
|
+
|
|
|
**\* REPLACE**
|
|
|
|
|
|
Replace specific columns in the result. It allows for the replacement of certain columns in the result by specifying new expressions, while other columns are still included in the output.
|
|
@@ -54,6 +66,12 @@ SELECT * REPLACE(expression1 as column_name1, expression2 as column_name2...)
|
|
|
FROM stream1
|
|
|
```
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * replace(a+b as c) from demo;
|
|
|
+```
|
|
|
+
|
|
|
REPLACE and EXCEPT can be used together, but it's important to note that if there is a conflict between these two operations, REPLACE takes precedence. In the following example, the final result will include the column_name1 field.
|
|
|
|
|
|
```sql
|
|
@@ -143,6 +161,12 @@ LEFT JOIN stream2
|
|
|
ON stream1.column_name = stream2.column_name;
|
|
|
```
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from stream1 left join on stream2 stream1.column = stream2.column group by countwindow(5);
|
|
|
+```
|
|
|
+
|
|
|
**RIGHT**
|
|
|
|
|
|
The RIGHT JOIN keyword returns all records from the right stream (stream2), and the matched records from the left stream (stream1). The result is NULL from the left side, when there is no match.
|
|
@@ -154,6 +178,12 @@ RIGHT JOIN stream2
|
|
|
ON stream1.column_name = stream2.column_name;
|
|
|
```
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from stream1 right join on stream2 stream1.column = stream2.column group by countwindow(5);
|
|
|
+```
|
|
|
+
|
|
|
**FULL**
|
|
|
|
|
|
The FULL JOIN keyword return all records when there is a match in left (stream1) or right (stream2) table records.
|
|
@@ -168,6 +198,12 @@ ON stream1.column_name = stream2.column_name
|
|
|
WHERE condition;
|
|
|
```
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from stream1 full join on stream2 stream1.column = stream2.column group by countwindow(5);
|
|
|
+```
|
|
|
+
|
|
|
**CROSS**
|
|
|
|
|
|
The CROSS JOIN is used to combine each row of the first stream (stream1) with each row of the second stream (stream2). It is also known as the Cartesian join since it returns the Cartesian product of the sets of rows from the joined tables. Let's say if there are **m** rows in stream1, and **n** rows in stream2, then the result of CROSS JOIN returns **m*n** rows.
|
|
@@ -182,6 +218,12 @@ ON stream1.column_name = stream2.column_name
|
|
|
WHERE condition;
|
|
|
```
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from stream1 cross outer join on stream2 stream1.column = stream2.column group by countwindow(5);
|
|
|
+```
|
|
|
+
|
|
|
**source_stream | source_stream_alias**
|
|
|
|
|
|
The input stream name or alias name to be joined.
|
|
@@ -206,6 +248,12 @@ WHERE <search_condition>
|
|
|
{ expression { = | < > | ! = | > | > = | < | < = } expression
|
|
|
```
|
|
|
|
|
|
+exmaple:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo where a > 10;
|
|
|
+```
|
|
|
+
|
|
|
### Arguments
|
|
|
|
|
|
Expression is a constant, function, any combination of column names, constants, and functions connected by an operator or operators.
|
|
@@ -218,10 +266,22 @@ Specifies the conditions for the rows returned in the result set for a SELECT st
|
|
|
|
|
|
Combines two conditions and evaluates to TRUE when both of the conditions are TRUE.
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo where a > 10 and a < 15;
|
|
|
+```
|
|
|
+
|
|
|
**OR**
|
|
|
|
|
|
Combines two conditions and evaluates to TRUE when either condition is TRUE.
|
|
|
|
|
|
+exmaple:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo where a > 10 or a < 15;
|
|
|
+```
|
|
|
+
|
|
|
**< predicate >**
|
|
|
|
|
|
Is an expression that returns TRUE or FALSE.
|
|
@@ -266,6 +326,12 @@ Is the operator used to test the condition of one expression in (not) within the
|
|
|
expression [NOT] BETWEEN expression1 AND expression2
|
|
|
```
|
|
|
|
|
|
+exmaple:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo where a between 10 and 15;
|
|
|
+```
|
|
|
+
|
|
|
**[NOT] LIKE**
|
|
|
|
|
|
Is the operator used to check if the STRING in the first operand matches a pattern specified by the second operand. Patterns can contain these characters:
|
|
@@ -283,6 +349,12 @@ Example:
|
|
|
a LIKE "string%"
|
|
|
```
|
|
|
|
|
|
+exmaple:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo where a like "prefix%"
|
|
|
+```
|
|
|
+
|
|
|
**[NOT] IN**
|
|
|
|
|
|
Is the operator used to test the condition of one expression (not) being part of to the other expression. support these two formats
|
|
@@ -338,6 +410,12 @@ FROM stream1
|
|
|
GROUP BY column_name
|
|
|
```
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo group by a, countwindow(5);
|
|
|
+```
|
|
|
+
|
|
|
### HAVING
|
|
|
|
|
|
The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions. Specifies a search condition for a group or an aggregate. HAVING can be used only with the SELECT expression. HAVING is typically used in a GROUP BY clause.
|
|
@@ -358,6 +436,12 @@ Specifies the search condition for the group or the aggregate to meet.
|
|
|
SELECT temp AS t, name FROM topic/sensor1 WHERE name = "dname" GROUP BY name HAVING count(name) > 3
|
|
|
```
|
|
|
|
|
|
+example:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo group by countwindow(5) having a > 10;
|
|
|
+```
|
|
|
+
|
|
|
## ORDER BY
|
|
|
|
|
|
Order the rows by values of one or more columns.
|
|
@@ -370,6 +454,12 @@ ORDER BY column1, column2, ... ASC|DESC
|
|
|
|
|
|
The ORDER BY statement in sql is used to sort the fetched data in either ascending or descending according to one or more columns.
|
|
|
|
|
|
+exmaple:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo group by countwindow(5) order by a ASC;
|
|
|
+```
|
|
|
+
|
|
|
- By default ORDER BY sorts the data in **ascending order.**
|
|
|
- The keyword DESC is used to sort the data in descending order and the keyword ASC to sort in ascending order.
|
|
|
|
|
@@ -403,6 +493,12 @@ The case expression evaluates a list of conditions and returns one of multiple p
|
|
|
|
|
|
There are two types of case expression: simple case expression and searched case expression.
|
|
|
|
|
|
+exmaple:
|
|
|
+
|
|
|
+```sql
|
|
|
+select * from demo where a > 10 group by countwindow(5) limit 10;
|
|
|
+```
|
|
|
+
|
|
|
### Simple Case Expression
|
|
|
|
|
|
The simple case expression compares an expression to a set of simple expressions to determine the result.
|