diff --git a/docs/en/10-programming/03-insert.md b/docs/en/10-programming/03-insert.md index 1360a2ec7a8bfdeeee2993b12752918328d3eb21..b31d38a44b22ccdb019f021254d94350c6c02a3e 100644 --- a/docs/en/10-programming/03-insert.md +++ b/docs/en/10-programming/03-insert.md @@ -10,7 +10,7 @@ import TabItem from '@theme/TabItem'; ## SQL Examples -Here are some brief examples for `INSET` statement. You can execute these statements manually by TDengine CLI or TDengine Cloud Explorer or programmatically by TDengine connectors. +Here are some brief examples for `INSERT` statement. You can execute these statements manually by TDengine CLI or TDengine Cloud Explorer or programmatically by TDengine connectors. ### Insert Single Row @@ -30,10 +30,10 @@ INSERT INTO test.d101 VALUES (1538548684000, 10.2, 220, 0.23) (1538548696650, 10 ### Insert into Multiple Tables -Data can be inserted into multiple tables in the same SQL statement. The example below inserts 2 rows into table "d101" and 1 row into table "d1002". +Data can be inserted into multiple tables in the same SQL statement. The example below inserts 2 rows into table "d101" and 1 row into table "d102". ```sql -INSERT INTO test.d101 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, 218, 0.33) d1002 VALUES (1538548696800, 12.3, 221, 0.31); +INSERT INTO test.d101 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, 218, 0.33) d102 VALUES (1538548696800, 12.3, 221, 0.31); ``` For more details about `INSERT` please refer to [INSERT](https://docs.tdengine.com/cloud/taos-sql/insert). diff --git a/docs/en/10-programming/04-query.md b/docs/en/10-programming/04-query.md index 02f599a45b15ffd5e8440c0410baaeb47dcc1cfd..404d138263715b4d1538f3293b500e699917ee84 100644 --- a/docs/en/10-programming/04-query.md +++ b/docs/en/10-programming/04-query.md @@ -49,22 +49,22 @@ In summary, records across subtables can be aggregated by a simple query on thei In [TDengine CLI](../tool/cli) `taos`, use the SQL below to get the average voltage of all the meters in California grouped by location. ```sql title="SQL" -SELECT AVG(voltage) FROM test.meters GROUP BY location; +SELECT location, AVG(voltage) FROM test.meters GROUP BY location; ``` ```txt title="output" - avg(voltage) | -============================ - 109.507000000 | - 109.507000000 | - 109.507000000 | - 109.507000000 | - 109.507000000 | - 109.507000000 | - 109.507000000 | - 109.507000000 | - 109.507000000 | - 109.507000000 | + location | avg(voltage) | +======================================================= + California.PaloAlto | 109.507000000 | + California.Sunnyvale | 109.507000000 | + California.MountainView | 109.507000000 | + California.SanFrancisco | 109.507000000 | + California.SanJose | 109.507000000 | + California.SanDiego | 109.507000000 | + California.SantaClara | 109.507000000 | + California.Cupertino | 109.507000000 | + California.Campbell | 109.507000000 | + California.LosAngles | 109.507000000 | Query OK, 10 row(s) in set ``` diff --git a/docs/en/12-stream.md b/docs/en/12-stream.md index c0f1e225d05115793e49382127b4a8428277ebad..66d8efddd4d35c43d41ddcf18d471dc28eb36b9c 100644 --- a/docs/en/12-stream.md +++ b/docs/en/12-stream.md @@ -40,28 +40,28 @@ Then create four subtables as follows: ```sql CREATE STABLE power.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int); -CREATE TABLE power.d101 USING meters TAGS ("California.SanFrancisco", 2); -CREATE TABLE power.d102 USING meters TAGS ("California.SanFrancisco", 3); -CREATE TABLE power.d103 USING meters TAGS ("California.LosAngeles", 2); -CREATE TABLE power.d104 USING meters TAGS ("California.LosAngeles", 3); +CREATE TABLE power.d101 USING power.meters TAGS ("California.SanFrancisco", 2); +CREATE TABLE power.d102 USING power.meters TAGS ("California.SanFrancisco", 3); +CREATE TABLE power.d103 USING power.meters TAGS ("California.LosAngeles", 2); +CREATE TABLE power.d104 USING power.meters TAGS ("California.LosAngeles", 3); ``` ### Create a Stream ```sql -create stream current_stream into current_stream_output_stb as select _wstart as start, _wend as end, max(current) as max_current from meters where voltage <= 220 interval (5s); +create stream current_stream into current_stream_output_stb as select _wstart as start, _wend as end, max(current) as max_current from power.meters where voltage <= 220 interval (5s); ``` ### Write Data ```sql -insert into d101 values("2018-10-03 14:38:05.000", 10.30000, 219, 0.31000); -insert into d101 values("2018-10-03 14:38:15.000", 12.60000, 218, 0.33000); -insert into d101 values("2018-10-03 14:38:16.800", 12.30000, 221, 0.31000); -insert into d102 values("2018-10-03 14:38:16.650", 10.30000, 218, 0.25000); -insert into d103 values("2018-10-03 14:38:05.500", 11.80000, 221, 0.28000); -insert into d103 values("2018-10-03 14:38:16.600", 13.40000, 223, 0.29000); -insert into d104 values("2018-10-03 14:38:05.000", 10.80000, 223, 0.29000); -insert into d104 values("2018-10-03 14:38:06.500", 11.50000, 221, 0.35000); +insert into power.d101 values("2018-10-03 14:38:05.000", 10.30000, 219, 0.31000); +insert into power.d101 values("2018-10-03 14:38:15.000", 12.60000, 218, 0.33000); +insert into power.d101 values("2018-10-03 14:38:16.800", 12.30000, 221, 0.31000); +insert into power.d102 values("2018-10-03 14:38:16.650", 10.30000, 218, 0.25000); +insert into power.d103 values("2018-10-03 14:38:05.500", 11.80000, 221, 0.28000); +insert into power.d103 values("2018-10-03 14:38:16.600", 13.40000, 223, 0.29000); +insert into power.d104 values("2018-10-03 14:38:05.000", 10.80000, 223, 0.29000); +insert into power.d104 values("2018-10-03 14:38:06.500", 11.50000, 221, 0.35000); ``` ### Query the Results @@ -90,7 +90,7 @@ The procedure from the previous scenario is used to create the database. ### Create a Stream ```sql -create stream power_stream into power_stream_output_stb as select ts, concat_ws(".", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname; +create stream power_stream into power_stream_output_stb as select ts, concat_ws(".", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from power.meters partition by tbname; ``` ### Write data @@ -99,7 +99,7 @@ The procedure from the previous scenario is used to write the data. ### Query the Results ```sql title="SQL" -taos> select ts, meter_location, active_power, reactive_power from power_stream_output_stb; +select ts, meter_location, active_power, reactive_power from power_stream_output_stb; ``` ```txt title="output" ts | meter_location | active_power | reactive_power |