QYYEE vor 5 Jahren
Ursprung
Commit
2d8918bed0
1 geänderte Dateien mit 24 neuen und 0 gelöschten Zeilen
  1. 24
    0
      实践/数据库/TDengine连续查询统计数据.md

+ 24
- 0
实践/数据库/TDengine连续查询统计数据.md Datei anzeigen

@@ -40,11 +40,16 @@
40 40
 
41 41
 # 连续查询语句尝试
42 42
 
43
+实时数据
43 44
 ```
44 45
 1、创建关于统计的超级表:create table liqun_nuode_1_1.superrealtj (ts timestamp, aal float, aam float, aah float, avl float, avm float, avh float, awl float, awm float, awh float, atl float, atm float, ath float, aldl float, aldm float, aldh float, bal float, bam float, bah float, bvl float, bvm float, bvh float, bwl float, bwm float, bwh float, btl float, btm float, bth float, bldl float, bldm float, bldh float, cal float, cam float, cah float, cvl float, cvm float, cvh float, cwl float, cwm float, cwh float, ctl float, ctm float, cth float, cldl float, cldm float, cldh float, nal float, nam float, nah float, ntl float, ntm float, nth float, nldl float, nldm float, nldh float) tags (mac binary(20), addr binary(5))
45 46
 
47
+
48
+
46 49
 2、定义把实时查询数据放入统计子表,并创建子表:create table liqun_nuode_1_1.realtj using liqun_nuode_1_1.superrealtj tags ('187ED5316058','1') as select MIN(aa), AVG(aa), MAX(aa), MIN(av), AVG(av), MAX(av), MIN(aw), AVG(aw), MAX(aw), MIN(at), AVG(at), MAX(at), MIN(ald) AVG(ald), MAX(ald), MIN(ba), AVG(ba), MAX(ba), MIN(bv), AVG(bv), MAX(bv), MIN(bw), AVG(bw), MAX(bw), MIN(bt), AVG(bt), MAX(bt), MIN(bld), AVG(bld), MAX(bld), MIN(ca), AVG(ca), MAX(ca), MIN(cv), AVG(cv), MAX(cv), MIN(cw), AVG(cw), MAX(cw), MIN(ct), AVG(ct), MAX(ct), MIN(cld), AVG(cld), MAX(cld), MIN(na), AVG(na), MAX(na), MIN(nt), AVG(nt), MAX(nt), MIN(nld), AVG(nld), MAX(nld) from liqun_nuode_1_1.superreal where mac='187ED5316058' and addr='1' INTERVAL(1M)
47 50
 
51
+
52
+
48 53
 (a表示毫秒,s表示秒,m表示分钟,h表示小时,d表示天,w表示周,n表示月,y表示年)
49 54
 
50 55
 3、查看:show streams
@@ -53,3 +58,22 @@
53 58
 5、查询:select * from liqun_nuode_1_1.superrealtj where '2018-06-01 08:00:00.000' AND ts <= '2018-06-02 08:00:00.000' AND mac='187ED5316058' AND adrr='1'
54 59
 
55 60
 ```
61
+
62
+报警统计
63
+```
64
+1、定义报警统计的超级表:create table liqun_nuode_1_1.superwarningtj (ts timestamp, typesl int, levelsl int) tags (mac binary(20), addr binary(5), type int, level int)
65
+
66
+2、报警统计实时查询定义,并保存到子表
67
+create table liqun_nuode_1_1.warningtj using liqun_nuode_1_1.superwarningtj tags ('187ED5316058','1',1,1) as select SUM(type), SUM(level) from liqun_nuode_1_1.superwarningtj where mac='187ED5316058' and addr='1' and type=1 and level=1 INTERVAL(1M)
68
+```
69
+
70
+开关统计
71
+```
72
+1、定义开关统计的超级表:
73
+create table liqun_nuode_1_1.superkgtj  (ts timestamp, sl int) tags (mac binary(20), addr binary(5), oc bool)
74
+
75
+2、开关统计实时查询定义,并保存到子表
76
+create table liqun_nuode_1_1.kgtj using liqun_nuode_1_1.superkgtj tags ('187ED5316058','1',true) as select from liqun_nuode_1_1.superkgtj where  mac='187ED5316058' and addr='1' and oc=true INTERVAL(1M)
77
+```
78
+
79
+    

Laden…
Abbrechen
Speichern