mirror of
https://github.com/taosdata/TDengine
synced 2026-05-24 10:09:01 +00:00
* 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
26 KiB
26 KiB
| 1 | taos> use test; |
|---|---|
| 2 | Database changed. |
| 3 | taos> select * from a1 a left join (select now 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 | NULL | NULL | NULL | NU. | |
| 7 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | |
| 8 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | |
| 9 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | |
| 10 | taos> select * from a1 a left join (select now 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 | NULL | NULL | NULL | NU. | |
| 14 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | |
| 15 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | |
| 16 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | |
| 17 | taos> select a.* from a1 a left join (select now 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:01.000 | 102 | 1012 | |
| 22 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 23 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 24 | taos> select b.* from a1 a left join (select now as ts, f, g, 'a' from b1) b on a.ts = b.ts; |
| 25 | ts | f | g | 'a' | |
| 26 | ============================================================ |
| 27 | NULL | NULL | NULL | NU. | |
| 28 | NULL | NULL | NULL | NU. | |
| 29 | NULL | NULL | NULL | NU. | |
| 30 | NULL | NULL | NULL | NU. | |
| 31 | taos> select b.* from a1 a left join (select now as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; |
| 32 | ts1 | f | g | 'a' | |
| 33 | ============================================================ |
| 34 | NULL | NULL | NULL | NU. | |
| 35 | NULL | NULL | NULL | NU. | |
| 36 | NULL | NULL | NULL | NU. | |
| 37 | NULL | NULL | NULL | NU. | |
| 38 | taos> select a.*, b.ts from a1 a left join (select now 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 | NULL | |
| 42 | __today__ 00:00:01.000 | 102 | 1012 | NULL | |
| 43 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | |
| 44 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | |
| 45 | taos> select b.c from a1 a left join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; |
| 46 | c | |
| 47 | ====== |
| 48 | NU. | |
| 49 | NU. | |
| 50 | NU. | |
| 51 | NU. | |
| 52 | taos> select b.ts from a1 a left join (select now as ts, f, g, 'a' c from b1) b on a.ts = b.ts; |
| 53 | ts | |
| 54 | ========================== |
| 55 | NULL | |
| 56 | NULL | |
| 57 | NULL | |
| 58 | NULL | |
| 59 | taos> select * from a1 a left join (select now 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 | NULL | NULL | NULL | NULL | NU. | |
| 63 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | |
| 64 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | |
| 65 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | |
| 66 | taos> select a.* from a1 a left join (select now 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:01.000 | 102 | 1012 | |
| 71 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 72 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 73 | taos> select b.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; |
| 74 | ts1 | ts | f | g | 'a' | |
| 75 | ====================================================================================== |
| 76 | NULL | NULL | NULL | NULL | NU. | |
| 77 | NULL | NULL | NULL | NULL | NU. | |
| 78 | NULL | NULL | NULL | NULL | NU. | |
| 79 | NULL | NULL | NULL | NULL | NU. | |
| 80 | taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; |
| 81 | c | |
| 82 | ====== |
| 83 | NU. | |
| 84 | NU. | |
| 85 | NU. | |
| 86 | NU. | |
| 87 | taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; |
| 88 | ts | f | g | |
| 89 | ====================================================== |
| 90 | __today__ 00:00:00.000 | 101 | 1011 | |
| 91 | __today__ 00:00:01.000 | 102 | 1012 | |
| 92 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 93 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 94 | taos> select b.ts1,a.ts from a1 a left join (select now as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; |
| 95 | ts1 | ts | |
| 96 | ==================================================== |
| 97 | NULL | __today__ 00:00:00.000 | |
| 98 | NULL | __today__ 00:00:01.000 | |
| 99 | NULL | __tomorrow__ 00:00:00.000 | |
| 100 | NULL | __tomorrow__ 00:00:02.000 | |
| 101 | taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; |
| 102 | ts | f | g | |
| 103 | ====================================================== |
| 104 | __today__ 00:00:00.000 | 101 | 1011 | |
| 105 | __today__ 00:00:01.000 | 102 | 1012 | |
| 106 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 107 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 108 | taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; |
| 109 | c | |
| 110 | ====== |
| 111 | a | |
| 112 | a | |
| 113 | a | |
| 114 | a | |
| 115 | taos> select b.ts from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; |
| 116 | ts | |
| 117 | ========================== |
| 118 | __today__ 00:00:00.000 | |
| 119 | __today__ 00:00:01.000 | |
| 120 | __tomorrow__ 00:00:00.000 | |
| 121 | __tomorrow__ 00:00:02.000 | |
| 122 | taos> select * from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 123 | ts | f | g | ts1 | ts | f | g | 'a' | |
| 124 | ============================================================================================================================================ |
| 125 | __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | |
| 126 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | |
| 127 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | |
| 128 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | |
| 129 | taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 130 | ts | f | g | |
| 131 | ====================================================== |
| 132 | __today__ 00:00:00.000 | 101 | 1011 | |
| 133 | __today__ 00:00:01.000 | 102 | 1012 | |
| 134 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 135 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 136 | taos> select b.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 137 | ts1 | ts | f | g | 'a' | |
| 138 | ====================================================================================== |
| 139 | NULL | NULL | NULL | NULL | NU. | |
| 140 | NULL | NULL | NULL | NULL | NU. | |
| 141 | NULL | NULL | NULL | NULL | NU. | |
| 142 | NULL | NULL | NULL | NULL | NU. | |
| 143 | taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 144 | c | |
| 145 | ====== |
| 146 | NU. | |
| 147 | NU. | |
| 148 | NU. | |
| 149 | NU. | |
| 150 | taos> select b.ts from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 151 | ts | |
| 152 | ========================== |
| 153 | NULL | |
| 154 | NULL | |
| 155 | NULL | |
| 156 | NULL | |
| 157 | taos> select * from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 158 | ts | f | g | ts1 | ts | f | g | 'a' | |
| 159 | ============================================================================================================================================ |
| 160 | __today__ 00:00:00.000 | 101 | 1011 | NULL | NULL | NULL | NULL | NU. | |
| 161 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | |
| 162 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | |
| 163 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | |
| 164 | taos> select a.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 165 | ts | f | g | |
| 166 | ====================================================== |
| 167 | __today__ 00:00:00.000 | 101 | 1011 | |
| 168 | __today__ 00:00:01.000 | 102 | 1012 | |
| 169 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 170 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 171 | taos> select b.* from a1 a left join (select now as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 172 | ts1 | ts | f | g | 'a' | |
| 173 | ====================================================================================== |
| 174 | NULL | NULL | NULL | NULL | NU. | |
| 175 | NULL | NULL | NULL | NULL | NU. | |
| 176 | NULL | NULL | NULL | NULL | NU. | |
| 177 | NULL | NULL | NULL | NULL | NU. | |
| 178 | taos> select b.c from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 179 | c | |
| 180 | ====== |
| 181 | NU. | |
| 182 | NU. | |
| 183 | NU. | |
| 184 | NU. | |
| 185 | taos> select b.ts from a1 a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 186 | ts | |
| 187 | ========================== |
| 188 | NULL | |
| 189 | NULL | |
| 190 | NULL | |
| 191 | NULL | |
| 192 | taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 193 | ts | |
| 194 | ========================== |
| 195 | NULL | |
| 196 | NULL | |
| 197 | NULL | |
| 198 | NULL | |
| 199 | taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from a1) a left join (select now as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 200 | ts | |
| 201 | ========================== |
| 202 | NULL | |
| 203 | NULL | |
| 204 | NULL | |
| 205 | NULL | |
| 206 | taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg1 from sta where tg1=1 partition by tg1 order by ts) ta left join (select now 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; |
| 207 | ts | val | tg1 | ts | val | tg1 | |
| 208 | ============================================================================================================ |
| 209 | __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | |
| 210 | taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left join (select now 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; |
| 211 | ts | val | tg2 | ts | val | tg2 | |
| 212 | ============================================================================================================ |
| 213 | __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | |
| 214 | __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | |
| 215 | taos> 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 left join (select now 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 ta.val; |
| 216 | ts | val | tg2 | ts | val | tg2 | |
| 217 | ============================================================================================================ |
| 218 | __today__ 00:00:00.000 | 101 | 1 | NULL | NULL | NULL | |
| 219 | __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | |
| 220 | __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | |
| 221 | __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | |
| 222 | __today__ 00:00:00.000 | 201 | 2 | NULL | NULL | NULL | |
| 223 | __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | |
| 224 | __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | |
| 225 | __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | |
| 226 | taos> 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 left join (select now 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=now where tb.ts=now order by tb.val; |
| 227 | taos> 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 left join (select now 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>now where tb.ts>now; |
| 228 | taos> select * from (select last(ts) as `ts`,last(f) as `val`,tg2 from sta where tg2>0 partition by tg2 order by ts) ta left 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; |
| 229 | ts | val | tg2 | ts | val | tg2 | |
| 230 | ============================================================================================================ |
| 231 | __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | |
| 232 | __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | |
| 233 | taos> select a.* from (select now as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; |
| 234 | ts | f | g | |
| 235 | ====================================================== |
| 236 | NULL | NULL | NULL | |
| 237 | NULL | NULL | NULL | |
| 238 | NULL | NULL | NULL | |
| 239 | NULL | NULL | NULL | |
| 240 | taos> select b.c from (select now as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; |
| 241 | c | |
| 242 | ====== |
| 243 | a | |
| 244 | a | |
| 245 | a | |
| 246 | a | |
| 247 | taos> select b.g from (select now as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; |
| 248 | g | |
| 249 | ============== |
| 250 | 3011 | |
| 251 | 3012 | |
| 252 | 3013 | |
| 253 | 3014 | |
| 254 | taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; |
| 255 | ts | f | g | |
| 256 | ====================================================== |
| 257 | NULL | NULL | NULL | |
| 258 | NULL | NULL | NULL | |
| 259 | NULL | NULL | NULL | |
| 260 | NULL | NULL | NULL | |
| 261 | taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; |
| 262 | c | |
| 263 | ====== |
| 264 | a | |
| 265 | a | |
| 266 | a | |
| 267 | a | |
| 268 | taos> select b.c from (select now as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; |
| 269 | c | |
| 270 | ====== |
| 271 | a | |
| 272 | a | |
| 273 | a | |
| 274 | a | |
| 275 | taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; |
| 276 | ts | f | g | |
| 277 | ====================================================== |
| 278 | __today__ 00:00:00.000 | 101 | 1011 | |
| 279 | __today__ 00:00:01.000 | 102 | 1012 | |
| 280 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 281 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 282 | taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; |
| 283 | c | |
| 284 | ====== |
| 285 | a | |
| 286 | a | |
| 287 | a | |
| 288 | a | |
| 289 | taos> select b.ts,a.* from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; |
| 290 | ts | ts | f | g | |
| 291 | ================================================================================ |
| 292 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 101 | 1011 | |
| 293 | __today__ 00:00:01.000 | __today__ 00:00:01.000 | 102 | 1012 | |
| 294 | __tomorrow__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 295 | __tomorrow__ 00:00:02.000 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 296 | taos> select a.*,b.ts from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 297 | ts | f | g | ts | |
| 298 | ================================================================================ |
| 299 | NULL | NULL | NULL | __today__ 00:00:00.000 | |
| 300 | NULL | NULL | NULL | __today__ 00:00:01.000 | |
| 301 | NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | |
| 302 | NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | |
| 303 | taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 304 | ts | f | g | |
| 305 | ====================================================== |
| 306 | NULL | NULL | NULL | |
| 307 | NULL | NULL | NULL | |
| 308 | NULL | NULL | NULL | |
| 309 | NULL | NULL | NULL | |
| 310 | taos> select b.ts,b.f from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 311 | ts | f | |
| 312 | ======================================== |
| 313 | __today__ 00:00:00.000 | 301 | |
| 314 | __today__ 00:00:01.000 | 302 | |
| 315 | __tomorrow__ 00:00:00.000 | 303 | |
| 316 | __tomorrow__ 00:00:02.000 | 304 | |
| 317 | taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 318 | c | |
| 319 | ====== |
| 320 | a | |
| 321 | a | |
| 322 | a | |
| 323 | a | |
| 324 | taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 325 | ts | |
| 326 | ========================== |
| 327 | __today__ 00:00:00.000 | |
| 328 | __today__ 00:00:01.000 | |
| 329 | __tomorrow__ 00:00:00.000 | |
| 330 | __tomorrow__ 00:00:02.000 | |
| 331 | taos> select b.ts, a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 332 | ts | ts | f | g | |
| 333 | ================================================================================ |
| 334 | __today__ 00:00:00.000 | NULL | NULL | NULL | |
| 335 | __today__ 00:00:01.000 | NULL | NULL | NULL | |
| 336 | __tomorrow__ 00:00:00.000 | NULL | NULL | NULL | |
| 337 | __tomorrow__ 00:00:02.000 | NULL | NULL | NULL | |
| 338 | taos> select a.* from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 339 | ts | f | g | |
| 340 | ====================================================== |
| 341 | NULL | NULL | NULL | |
| 342 | NULL | NULL | NULL | |
| 343 | NULL | NULL | NULL | |
| 344 | NULL | NULL | NULL | |
| 345 | taos> select b.g from (select now as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 346 | g | |
| 347 | ============== |
| 348 | 3011 | |
| 349 | 3012 | |
| 350 | 3013 | |
| 351 | 3014 | |
| 352 | taos> select b.c from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 353 | c | |
| 354 | ====== |
| 355 | a | |
| 356 | a | |
| 357 | a | |
| 358 | a | |
| 359 | taos> select b.ts from (select now as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 360 | ts | |
| 361 | ========================== |
| 362 | __today__ 00:00:00.000 | |
| 363 | __today__ 00:00:01.000 | |
| 364 | __tomorrow__ 00:00:00.000 | |
| 365 | __tomorrow__ 00:00:02.000 | |
| 366 | taos> select tb.val,tb.tg1,ta.* from (select now ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb left 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; |
| 367 | val | tg1 | ts | val | tg1 | |
| 368 | ================================================================================== |
| 369 | 404 | 1 | NULL | NULL | NULL | |
| 370 | taos> select tb.val,tb.tg2,ta.* from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb left 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; |
| 371 | val | tg2 | ts | val | tg2 | |
| 372 | ================================================================================== |
| 373 | 304 | 1 | NULL | NULL | NULL | |
| 374 | 404 | 2 | NULL | NULL | NULL | |
| 375 | taos> select tb.val,tb.tg2,ta.* from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb left 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; |
| 376 | val | tg2 | ts | val | tg2 | |
| 377 | ================================================================================== |
| 378 | 301 | 1 | NULL | NULL | NULL | |
| 379 | 302 | 1 | NULL | NULL | NULL | |
| 380 | 303 | 1 | NULL | NULL | NULL | |
| 381 | 304 | 1 | NULL | NULL | NULL | |
| 382 | 401 | 2 | NULL | NULL | NULL | |
| 383 | 402 | 2 | NULL | NULL | NULL | |
| 384 | 403 | 2 | NULL | NULL | NULL | |
| 385 | 404 | 2 | NULL | NULL | NULL | |
| 386 | taos> select * from (select now ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts desc) tb left 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>now where tb.ts>now; |