TDengine/tests/army/query/joinConst/inner.today.csv
Pan Wei 0cb0e109a7
enh: add more cases for constant join (#30225)
* fix: add more cases and fix issues

* enh: add more test cases

* enh: add more test cases

* fix: memory leak issue

* enh: add view cases and fix order by issue

* enh: add document description
2025-03-19 16:50:44 +08:00

62 KiB

1taos> use test;
2Database changed.
3taos> select * from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts;
4 ts | f | g | ts | f | g | 'a' |
5==================================================================================================================
6 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a |
7 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a |
8 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a |
9 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a |
10taos> select * from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1;
11 ts | f | g | ts1 | f | g | 'a' |
12==================================================================================================================
13 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a |
14 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a |
15 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a |
16 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a |
17taos> select a.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts;
18 ts | f | g |
19======================================================
20 __today__ 00:00:00.000 | 101 | 1011 |
21 __today__ 00:00:00.000 | 101 | 1011 |
22 __today__ 00:00:00.000 | 101 | 1011 |
23 __today__ 00:00:00.000 | 101 | 1011 |
24taos> select b.* from a1 a join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts;
25 ts | f | g | 'a' |
26============================================================
27 __today__ 00:00:00.000 | 301 | 3011 | a |
28 __today__ 00:00:00.000 | 302 | 3012 | a |
29 __today__ 00:00:00.000 | 303 | 3013 | a |
30 __today__ 00:00:00.000 | 304 | 3014 | a |
31taos> select b.* from a1 a join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1;
32 ts1 | f | g | 'a' |
33============================================================
34 __today__ 00:00:00.000 | 301 | 3011 | a |
35 __today__ 00:00:00.000 | 302 | 3012 | a |
36 __today__ 00:00:00.000 | 303 | 3013 | a |
37 __today__ 00:00:00.000 | 304 | 3014 | a |
38taos> select a.*, b.ts from a1 a join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1;
39 ts | f | g | ts |
40================================================================================
41 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 |
42 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 |
43 __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 |
44 __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 |
45taos> select b.c from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts;
46 c |
47======
48 a |
49 a |
50 a |
51 a |
52taos> select b.ts from a1 a join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts;
53 ts |
54==========================
55 __today__ 00:00:00.000 |
56 __today__ 00:00:00.000 |
57 __today__ 00:00:00.000 |
58 __today__ 00:00:00.000 |
59taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts;
60 ts | f | g | ts1 | ts | f | g | 'a' |
61============================================================================================================================================
62 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
63 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
64 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
65 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
66taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts;
67 ts | f | g |
68======================================================
69 __today__ 00:00:00.000 | 101 | 1011 |
70 __today__ 00:00:00.000 | 101 | 1011 |
71 __today__ 00:00:00.000 | 101 | 1011 |
72 __today__ 00:00:00.000 | 101 | 1011 |
73taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts;
74 ts1 | ts | f | g | 'a' |
75======================================================================================
76 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
77 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
78 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
79 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
80taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts;
81 c |
82======
83 a |
84 a |
85 a |
86 a |
87taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;
88 ts | f | g | ts1 | ts | f | g | c |
89============================================================================================================================================
90 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
91 __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
92 __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
93 __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
94taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;
95 ts | f | g |
96======================================================
97 __today__ 00:00:00.000 | 101 | 1011 |
98 __today__ 00:00:01.000 | 102 | 1012 |
99 __tomorrow__ 00:00:00.000 | 103 | 1013 |
100 __tomorrow__ 00:00:02.000 | 104 | 1014 |
101taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts;
102 ts1 | ts | f | g | c |
103======================================================================================
104 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
105 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
106 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
107 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
108taos> select b.ts1,a.ts from a1 a join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts;
109 ts1 | ts |
110====================================================
111 __today__ 00:00:00.000 | __today__ 00:00:00.000 |
112 __today__ 00:00:00.000 | __today__ 00:00:00.000 |
113 __today__ 00:00:00.000 | __today__ 00:00:00.000 |
114 __today__ 00:00:00.000 | __today__ 00:00:00.000 |
115taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts;
116 ts | f | g | ts1 | ts | f | g | 'a' |
117============================================================================================================================================
118 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
119 __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
120 __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
121 __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
122taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts;
123 ts | f | g |
124======================================================
125 __today__ 00:00:00.000 | 101 | 1011 |
126 __today__ 00:00:01.000 | 102 | 1012 |
127 __tomorrow__ 00:00:00.000 | 103 | 1013 |
128 __tomorrow__ 00:00:02.000 | 104 | 1014 |
129taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts;
130 ts1 | ts | f | g | 'a' |
131======================================================================================
132 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
133 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
134 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
135 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
136taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts;
137 c |
138======
139 a |
140 a |
141 a |
142 a |
143taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts;
144 ts |
145==========================
146 __today__ 00:00:00.000 |
147 __today__ 00:00:01.000 |
148 __tomorrow__ 00:00:00.000 |
149 __tomorrow__ 00:00:02.000 |
150taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts;
151 ts | f | g | ts1 | ts | f | g | 'a' |
152============================================================================================================================================
153 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
154taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts;
155 ts | f | g |
156======================================================
157 __today__ 00:00:00.000 | 101 | 1011 |
158taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts;
159 ts1 | ts | f | g | 'a' |
160======================================================================================
161 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
162taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts;
163 c |
164======
165 a |
166taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts;
167 ts |
168==========================
169 __today__ 00:00:00.000 |
170taos> select * from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1;
171 ts | f | g | ts1 | ts | f | g | 'a' |
172============================================================================================================================================
173 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
174taos> select a.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1;
175 ts | f | g |
176======================================================
177 __today__ 00:00:00.000 | 101 | 1011 |
178taos> select b.* from a1 a join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1;
179 ts1 | ts | f | g | 'a' |
180======================================================================================
181 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
182taos> select b.c from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1;
183 c |
184======
185 a |
186taos> select b.ts from a1 a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1;
187 ts |
188==========================
189 __today__ 00:00:00.000 |
190taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1;
191 ts |
192==========================
193 __today__ 00:00:00.000 |
194taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts;
195 ts |
196==========================
197 __today__ 00:00:00.000 |
198 __today__ 00:00:01.000 |
199 __tomorrow__ 00:00:00.000 |
200 __tomorrow__ 00:00:02.000 |
201taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts;
202 ts |
203==========================
204 __today__ 00:00:00.000 |
205 __today__ 00:00:01.000 |
206 __tomorrow__ 00:00:00.000 |
207 __tomorrow__ 00:00:02.000 |
208taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by ts desc) a join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1;
209 ts |
210==========================
211 __today__ 00:00:00.000 |
212taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1;
213taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta join (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb on ta.ts=tb.ts and ta.tg1=tb.tg1;
214taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2;
215taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;
216 ts | val | tg2 | ts | val | tg2 |
217============================================================================================================
218 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 |
219 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 |
220 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 |
221 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 |
222 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 |
223 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 |
224 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 |
225 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 |
226taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val;
227 ts | val | tg2 | ts | val | tg2 |
228============================================================================================================
229 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 |
230 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 |
231 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 |
232 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 |
233 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 |
234 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 |
235 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 |
236 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 |
237taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta join (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today;
238taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta join (select today() + 1d +3s ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb on ta.ts=tb.ts and ta.tg2=tb.tg2;
239 ts | val | tg2 | ts | val | tg2 |
240============================================================================================================
241 __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 |
242taos> select * from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;
243 ts | f | g | 'a' | ts | f | g |
244==================================================================================================================
245 __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
246 __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 |
247 __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 |
248 __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 |
249taos> select * from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1;
250 ts1 | f | g | 'a' | ts | f | g |
251==================================================================================================================
252 __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
253 __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 |
254 __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 |
255 __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 |
256taos> select a.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;
257 ts | f | g |
258======================================================
259 __today__ 00:00:00.000 | 101 | 1011 |
260 __today__ 00:00:00.000 | 101 | 1011 |
261 __today__ 00:00:00.000 | 101 | 1011 |
262 __today__ 00:00:00.000 | 101 | 1011 |
263taos> select b.* from (select today as ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;
264 ts | f | g | 'a' |
265============================================================
266 __today__ 00:00:00.000 | 301 | 3011 | a |
267 __today__ 00:00:00.000 | 302 | 3012 | a |
268 __today__ 00:00:00.000 | 303 | 3013 | a |
269 __today__ 00:00:00.000 | 304 | 3014 | a |
270taos> select b.* from (select today as ts1, f, g, 'a' from b1) b join a1 a on a.ts = b.ts1;
271 ts1 | f | g | 'a' |
272============================================================
273 __today__ 00:00:00.000 | 301 | 3011 | a |
274 __today__ 00:00:00.000 | 302 | 3012 | a |
275 __today__ 00:00:00.000 | 303 | 3013 | a |
276 __today__ 00:00:00.000 | 304 | 3014 | a |
277taos> select b.c from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts;
278 c |
279======
280 a |
281 a |
282 a |
283 a |
284taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts;
285 ts |
286==========================
287 __today__ 00:00:00.000 |
288 __today__ 00:00:00.000 |
289 __today__ 00:00:00.000 |
290 __today__ 00:00:00.000 |
291taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts;
292 ts1 | ts | f | g | 'a' | ts | f | g |
293============================================================================================================================================
294 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
295 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 |
296 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 |
297 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 |
298taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts;
299 ts | f | g |
300======================================================
301 __today__ 00:00:00.000 | 101 | 1011 |
302 __today__ 00:00:00.000 | 101 | 1011 |
303 __today__ 00:00:00.000 | 101 | 1011 |
304 __today__ 00:00:00.000 | 101 | 1011 |
305taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts;
306 ts1 | ts | f | g | 'a' |
307======================================================================================
308 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
309 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
310 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
311 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
312taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts;
313 c |
314======
315 a |
316 a |
317 a |
318 a |
319taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts;
320 ts1 |
321==========================
322 __today__ 00:00:00.000 |
323 __today__ 00:00:00.000 |
324 __today__ 00:00:00.000 |
325 __today__ 00:00:00.000 |
326taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;
327 ts1 | ts | f | g | 'a' | ts | f | g |
328============================================================================================================================================
329 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
330 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 |
331 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 |
332 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 |
333taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;
334 ts | f | g |
335======================================================
336 __today__ 00:00:00.000 | 101 | 1011 |
337 __today__ 00:00:01.000 | 102 | 1012 |
338 __tomorrow__ 00:00:00.000 | 103 | 1013 |
339 __tomorrow__ 00:00:02.000 | 104 | 1014 |
340taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on a.ts = b.ts;
341 ts1 | ts | f | g | 'a' |
342======================================================================================
343 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
344 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
345 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
346 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
347taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts;
348 c |
349======
350 a |
351 a |
352 a |
353 a |
354taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on a.ts = b.ts;
355 ts |
356==========================
357 __today__ 00:00:00.000 |
358 __today__ 00:00:01.000 |
359 __tomorrow__ 00:00:00.000 |
360 __tomorrow__ 00:00:02.000 |
361taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts;
362 ts1 | ts | f | g | 'a' | ts | f | g |
363============================================================================================================================================
364 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
365taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts;
366 ts | f | g |
367======================================================
368 __today__ 00:00:00.000 | 101 | 1011 |
369taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts;
370 ts1 | ts | f | g | 'a' |
371======================================================================================
372 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
373taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts;
374 c |
375======
376 a |
377taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts1 = a.ts and a.ts = b.ts;
378 ts |
379==========================
380 __today__ 00:00:00.000 |
381taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1;
382 ts1 | ts | f | g | 'a' | ts | f | g |
383============================================================================================================================================
384 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
385taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1;
386 ts | f | g |
387======================================================
388 __today__ 00:00:00.000 | 101 | 1011 |
389taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1;
390 ts1 | ts | f | g | 'a' |
391======================================================================================
392 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
393taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1;
394 c |
395======
396 a |
397taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b join a1 a on b.ts = a.ts and a.ts = b.ts1;
398 ts |
399==========================
400 __today__ 00:00:00.000 |
401taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta on ta.ts=tb.ts and ta.tg1=tb.tg1;
402taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2;
403taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;;
404 ts | val | tg2 | ts | val | tg2 |
405============================================================================================================
406 __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 |
407 __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 |
408 __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 |
409 __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 |
410 __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 |
411 __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 |
412 __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 |
413 __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 |
414taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today where tb.ts=today order by tb.val;
415 ts | val | tg2 | ts | val | tg2 |
416============================================================================================================
417 __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 |
418 __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 |
419 __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 |
420 __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 |
421 __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 |
422 __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 |
423 __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 |
424 __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 |
425taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb join (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta on ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today where tb.ts>today;
426taos> select * from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts;
427 ts | f | g | ts | f | g | 'a' |
428==================================================================================================================
429 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a |
430 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a |
431 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a |
432 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a |
433taos> select * from a1 a , (select today as ts1, f, g, 'a' from b1) b where a.ts = b.ts1;
434 ts | f | g | ts1 | f | g | 'a' |
435==================================================================================================================
436 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a |
437 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a |
438 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a |
439 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a |
440taos> select a.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts;
441 ts | f | g |
442======================================================
443 __today__ 00:00:00.000 | 101 | 1011 |
444 __today__ 00:00:00.000 | 101 | 1011 |
445 __today__ 00:00:00.000 | 101 | 1011 |
446 __today__ 00:00:00.000 | 101 | 1011 |
447taos> select b.* from a1 a , (select today as ts, f, g, 'a' from b1) b where a.ts = b.ts;
448 ts | f | g | 'a' |
449============================================================
450 __today__ 00:00:00.000 | 301 | 3011 | a |
451 __today__ 00:00:00.000 | 302 | 3012 | a |
452 __today__ 00:00:00.000 | 303 | 3013 | a |
453 __today__ 00:00:00.000 | 304 | 3014 | a |
454taos> select b.c from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts;
455 c |
456======
457 a |
458 a |
459 a |
460 a |
461taos> select b.ts from a1 a , (select today as ts, f, g, 'a' c from b1) b where a.ts = b.ts;
462 ts |
463==========================
464 __today__ 00:00:00.000 |
465 __today__ 00:00:00.000 |
466 __today__ 00:00:00.000 |
467 __today__ 00:00:00.000 |
468taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where a.ts = b.ts1;
469 ts1 |
470==========================
471 __today__ 00:00:00.000 |
472 __today__ 00:00:00.000 |
473 __today__ 00:00:00.000 |
474 __today__ 00:00:00.000 |
475taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts;
476 ts | f | g | ts1 | ts | f | g | 'a' |
477============================================================================================================================================
478 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
479 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
480 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
481 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
482taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts;
483 ts | f | g |
484======================================================
485 __today__ 00:00:00.000 | 101 | 1011 |
486 __today__ 00:00:00.000 | 101 | 1011 |
487 __today__ 00:00:00.000 | 101 | 1011 |
488 __today__ 00:00:00.000 | 101 | 1011 |
489taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts;
490 ts1 | ts | f | g | 'a' |
491======================================================================================
492 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
493 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
494 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
495 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
496taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts;
497 c |
498======
499 a |
500 a |
501 a |
502 a |
503taos> select b.ts1 from a1 a , (select today as ts1, f, g, 'a' c from b1) b where b.ts1 = a.ts;
504 ts1 |
505==========================
506 __today__ 00:00:00.000 |
507 __today__ 00:00:00.000 |
508 __today__ 00:00:00.000 |
509 __today__ 00:00:00.000 |
510taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts;
511 ts | f | g | ts1 | ts | f | g | 'a' |
512============================================================================================================================================
513 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
514 __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
515 __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
516 __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
517taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts;
518 ts | f | g |
519======================================================
520 __today__ 00:00:00.000 | 101 | 1011 |
521 __today__ 00:00:01.000 | 102 | 1012 |
522 __tomorrow__ 00:00:00.000 | 103 | 1013 |
523 __tomorrow__ 00:00:02.000 | 104 | 1014 |
524taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where a.ts = b.ts;
525 ts1 | ts | f | g | 'a' |
526======================================================================================
527 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
528 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
529 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
530 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
531taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts;
532 c |
533======
534 a |
535 a |
536 a |
537 a |
538taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where a.ts = b.ts;
539 ts |
540==========================
541 __today__ 00:00:00.000 |
542 __today__ 00:00:01.000 |
543 __tomorrow__ 00:00:00.000 |
544 __tomorrow__ 00:00:02.000 |
545taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts;
546 ts | f | g | ts1 | ts | f | g | 'a' |
547============================================================================================================================================
548 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
549taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts;
550 ts | f | g |
551======================================================
552 __today__ 00:00:00.000 | 101 | 1011 |
553taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts1 = a.ts and a.ts = b.ts;
554 ts1 | ts | f | g | 'a' |
555======================================================================================
556 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
557taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts;
558 c |
559======
560 a |
561taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts and a.ts = b.ts;
562 ts |
563==========================
564 __today__ 00:00:00.000 |
565taos> select * from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1;
566 ts | f | g | ts1 | ts | f | g | 'a' |
567============================================================================================================================================
568 __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
569taos> select a.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1;
570 ts | f | g |
571======================================================
572 __today__ 00:00:00.000 | 101 | 1011 |
573taos> select b.* from a1 a , (select today as ts1, ts, f, g, 'a' from b1) b where b.ts = a.ts and a.ts = b.ts1;
574 ts1 | ts | f | g | 'a' |
575======================================================================================
576 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
577taos> select b.c from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1;
578 c |
579======
580 a |
581taos> select b.ts from a1 a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1;
582 ts |
583==========================
584 __today__ 00:00:00.000 |
585taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1;
586 ts |
587==========================
588 __today__ 00:00:00.000 |
589taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts;
590 ts |
591==========================
592 __today__ 00:00:00.000 |
593 __today__ 00:00:01.000 |
594 __tomorrow__ 00:00:00.000 |
595 __tomorrow__ 00:00:02.000 |
596taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts1 = a.ts1 and a.ts = b.ts;
597 ts |
598==========================
599 __today__ 00:00:00.000 |
600 __today__ 00:00:01.000 |
601 __tomorrow__ 00:00:00.000 |
602 __tomorrow__ 00:00:02.000 |
603taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by ts) a , (select today as ts1, ts, f, g, 'a' c from b1) b where b.ts = a.ts and a.ts = b.ts1;
604 ts |
605==========================
606 __today__ 00:00:00.000 |
607taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta , (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb where ta.ts=tb.ts and ta.tg1=tb.tg1;
608taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2;
609taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;
610 ts | val | tg2 | ts | val | tg2 |
611============================================================================================================
612 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 |
613 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 |
614 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 |
615 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 |
616 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 |
617 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 |
618 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 |
619 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 |
620taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val;
621 ts | val | tg2 | ts | val | tg2 |
622============================================================================================================
623 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 |
624 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 |
625 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 |
626 __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 |
627 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 |
628 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 |
629 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 |
630 __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 |
631taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta , (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ;
632taos> select * from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;
633 ts | f | g | 'a' | ts | f | g |
634==================================================================================================================
635 __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
636 __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 |
637 __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 |
638 __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 |
639taos> select * from (select today as ts1, f, g, 'a' from b1) b , a1 a where a.ts = b.ts1;
640 ts1 | f | g | 'a' | ts | f | g |
641==================================================================================================================
642 __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
643 __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 |
644 __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 |
645 __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 |
646taos> select a.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;
647 ts | f | g |
648======================================================
649 __today__ 00:00:00.000 | 101 | 1011 |
650 __today__ 00:00:00.000 | 101 | 1011 |
651 __today__ 00:00:00.000 | 101 | 1011 |
652 __today__ 00:00:00.000 | 101 | 1011 |
653taos> select b.* from (select today as ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;
654 ts | f | g | 'a' |
655============================================================
656 __today__ 00:00:00.000 | 301 | 3011 | a |
657 __today__ 00:00:00.000 | 302 | 3012 | a |
658 __today__ 00:00:00.000 | 303 | 3013 | a |
659 __today__ 00:00:00.000 | 304 | 3014 | a |
660taos> select b.c from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts;
661 c |
662======
663 a |
664 a |
665 a |
666 a |
667taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts;
668 ts |
669==========================
670 __today__ 00:00:00.000 |
671 __today__ 00:00:00.000 |
672 __today__ 00:00:00.000 |
673 __today__ 00:00:00.000 |
674taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts1;
675 ts1 |
676==========================
677 __today__ 00:00:00.000 |
678 __today__ 00:00:00.000 |
679 __today__ 00:00:00.000 |
680 __today__ 00:00:00.000 |
681taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts;
682 ts1 | ts | f | g | 'a' | ts | f | g |
683============================================================================================================================================
684 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
685 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 |
686 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 |
687 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 |
688taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts;
689 ts | f | g |
690======================================================
691 __today__ 00:00:00.000 | 101 | 1011 |
692 __today__ 00:00:00.000 | 101 | 1011 |
693 __today__ 00:00:00.000 | 101 | 1011 |
694 __today__ 00:00:00.000 | 101 | 1011 |
695taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts;
696 ts1 | ts | f | g | 'a' |
697======================================================================================
698 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
699 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
700 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
701 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
702taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts;
703 c |
704======
705 a |
706 a |
707 a |
708 a |
709taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts;
710 ts1 |
711==========================
712 __today__ 00:00:00.000 |
713 __today__ 00:00:00.000 |
714 __today__ 00:00:00.000 |
715 __today__ 00:00:00.000 |
716taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;
717 ts1 | ts | f | g | 'a' | ts | f | g |
718============================================================================================================================================
719 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
720 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 |
721 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 |
722 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 |
723taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;
724 ts | f | g |
725======================================================
726 __today__ 00:00:00.000 | 101 | 1011 |
727 __today__ 00:00:01.000 | 102 | 1012 |
728 __tomorrow__ 00:00:00.000 | 103 | 1013 |
729 __tomorrow__ 00:00:02.000 | 104 | 1014 |
730taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where a.ts = b.ts;
731 ts1 | ts | f | g | 'a' |
732======================================================================================
733 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
734 __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a |
735 __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a |
736 __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a |
737taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts;
738 c |
739======
740 a |
741 a |
742 a |
743 a |
744taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where a.ts = b.ts;
745 ts |
746==========================
747 __today__ 00:00:00.000 |
748 __today__ 00:00:01.000 |
749 __tomorrow__ 00:00:00.000 |
750 __tomorrow__ 00:00:02.000 |
751taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts;
752 ts1 | ts | f | g | 'a' | ts | f | g |
753============================================================================================================================================
754 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
755taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts;
756 ts | f | g |
757======================================================
758 __today__ 00:00:00.000 | 101 | 1011 |
759taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts;
760 ts1 | ts | f | g | 'a' |
761======================================================================================
762 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
763taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts;
764 c |
765======
766 a |
767taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts1 = a.ts and a.ts = b.ts;
768 ts |
769==========================
770 __today__ 00:00:00.000 |
771taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1;
772 ts1 | ts | f | g | 'a' | ts | f | g |
773============================================================================================================================================
774 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 |
775taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1;
776 ts | f | g |
777======================================================
778 __today__ 00:00:00.000 | 101 | 1011 |
779taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1;
780 ts1 | ts | f | g | 'a' |
781======================================================================================
782 __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a |
783taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1;
784 c |
785======
786 a |
787taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b , a1 a where b.ts = a.ts and a.ts = b.ts1;
788 ts |
789==========================
790 __today__ 00:00:00.000 |
791taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta where ta.ts=tb.ts and ta.tg1=tb.tg1;
792taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2;
793taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 order by tb.val;
794 ts | val | tg2 | ts | val | tg2 |
795============================================================================================================
796 __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 |
797 __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 |
798 __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 |
799 __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 |
800 __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 |
801 __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 |
802 __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 |
803 __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 |
804taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts=today order by tb.val;
805 ts | val | tg2 | ts | val | tg2 |
806============================================================================================================
807 __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 |
808 __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 |
809 __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 |
810 __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 |
811 __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 |
812 __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 |
813 __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 |
814 __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 |
815taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb , (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 interval(1s) order by ts) ta where ta.ts=tb.ts and ta.tg2=tb.tg2 and tb.ts>today ;