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
43 KiB
43 KiB
| 1 | taos> use test; |
|---|---|
| 2 | Database changed. |
| 3 | taos> select * from a1 a left 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 | |
| 10 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | |
| 11 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | |
| 12 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | |
| 13 | taos> select * from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; |
| 14 | ts | f | g | ts1 | f | g | 'a' | |
| 15 | ================================================================================================================== |
| 16 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 17 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 302 | 3012 | a | |
| 18 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 303 | 3013 | a | |
| 19 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | 304 | 3014 | a | |
| 20 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NU. | |
| 21 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NU. | |
| 22 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NU. | |
| 23 | taos> select a.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; |
| 24 | ts | f | g | |
| 25 | ====================================================== |
| 26 | __today__ 00:00:00.000 | 101 | 1011 | |
| 27 | __today__ 00:00:00.000 | 101 | 1011 | |
| 28 | __today__ 00:00:00.000 | 101 | 1011 | |
| 29 | __today__ 00:00:00.000 | 101 | 1011 | |
| 30 | __today__ 00:00:01.000 | 102 | 1012 | |
| 31 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 32 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 33 | taos> select b.* from a1 a left join (select today as ts, f, g, 'a' from b1) b on a.ts = b.ts; |
| 34 | ts | f | g | 'a' | |
| 35 | ============================================================ |
| 36 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 37 | __today__ 00:00:00.000 | 302 | 3012 | a | |
| 38 | __today__ 00:00:00.000 | 303 | 3013 | a | |
| 39 | __today__ 00:00:00.000 | 304 | 3014 | a | |
| 40 | NULL | NULL | NULL | NU. | |
| 41 | NULL | NULL | NULL | NU. | |
| 42 | NULL | NULL | NULL | NU. | |
| 43 | taos> select b.* from a1 a left join (select today as ts1, f, g, 'a' from b1) b on a.ts = b.ts1; |
| 44 | ts1 | f | g | 'a' | |
| 45 | ============================================================ |
| 46 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 47 | __today__ 00:00:00.000 | 302 | 3012 | a | |
| 48 | __today__ 00:00:00.000 | 303 | 3013 | a | |
| 49 | __today__ 00:00:00.000 | 304 | 3014 | a | |
| 50 | NULL | NULL | NULL | NU. | |
| 51 | NULL | NULL | NULL | NU. | |
| 52 | NULL | NULL | NULL | NU. | |
| 53 | taos> select a.*, b.ts from a1 a left join (select today as ts1,ts, f, g, 'a' from b1) b on a.ts = b.ts1; |
| 54 | ts | f | g | ts | |
| 55 | ================================================================================ |
| 56 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | |
| 57 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:01.000 | |
| 58 | __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:00.000 | |
| 59 | __today__ 00:00:00.000 | 101 | 1011 | __tomorrow__ 00:00:02.000 | |
| 60 | __today__ 00:00:01.000 | 102 | 1012 | NULL | |
| 61 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | |
| 62 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | |
| 63 | taos> select b.c from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; |
| 64 | c | |
| 65 | ====== |
| 66 | a | |
| 67 | a | |
| 68 | a | |
| 69 | a | |
| 70 | NU. | |
| 71 | NU. | |
| 72 | NU. | |
| 73 | taos> select b.ts from a1 a left join (select today as ts, f, g, 'a' c from b1) b on a.ts = b.ts; |
| 74 | ts | |
| 75 | ========================== |
| 76 | __today__ 00:00:00.000 | |
| 77 | __today__ 00:00:00.000 | |
| 78 | __today__ 00:00:00.000 | |
| 79 | __today__ 00:00:00.000 | |
| 80 | NULL | |
| 81 | NULL | |
| 82 | NULL | |
| 83 | taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; |
| 84 | ts | f | g | ts1 | ts | f | g | 'a' | |
| 85 | ============================================================================================================================================ |
| 86 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 87 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 88 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 89 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 90 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | |
| 91 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | |
| 92 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | |
| 93 | taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; |
| 94 | ts | f | g | |
| 95 | ====================================================== |
| 96 | __today__ 00:00:00.000 | 101 | 1011 | |
| 97 | __today__ 00:00:00.000 | 101 | 1011 | |
| 98 | __today__ 00:00:00.000 | 101 | 1011 | |
| 99 | __today__ 00:00:00.000 | 101 | 1011 | |
| 100 | __today__ 00:00:01.000 | 102 | 1012 | |
| 101 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 102 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 103 | taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts; |
| 104 | ts1 | ts | f | g | 'a' | |
| 105 | ====================================================================================== |
| 106 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 107 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 108 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 109 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 110 | NULL | NULL | NULL | NULL | NU. | |
| 111 | NULL | NULL | NULL | NULL | NU. | |
| 112 | NULL | NULL | NULL | NULL | NU. | |
| 113 | taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts; |
| 114 | c | |
| 115 | ====== |
| 116 | a | |
| 117 | a | |
| 118 | a | |
| 119 | a | |
| 120 | NU. | |
| 121 | NU. | |
| 122 | NU. | |
| 123 | taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; |
| 124 | ts | f | g | ts1 | ts | f | g | c | |
| 125 | ============================================================================================================================================ |
| 126 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 127 | __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 128 | __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 129 | __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 130 | taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; |
| 131 | ts | f | g | |
| 132 | ====================================================== |
| 133 | __today__ 00:00:00.000 | 101 | 1011 | |
| 134 | __today__ 00:00:01.000 | 102 | 1012 | |
| 135 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 136 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 137 | taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts; |
| 138 | ts1 | ts | f | g | c | |
| 139 | ====================================================================================== |
| 140 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 141 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 142 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 143 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 144 | taos> select b.ts1,a.ts from a1 a left join (select today as ts1, f, g, 'a' c from b1) b on b.ts1 = a.ts; |
| 145 | ts1 | ts | |
| 146 | ==================================================== |
| 147 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | |
| 148 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | |
| 149 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | |
| 150 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | |
| 151 | NULL | __today__ 00:00:01.000 | |
| 152 | NULL | __tomorrow__ 00:00:00.000 | |
| 153 | NULL | __tomorrow__ 00:00:02.000 | |
| 154 | taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; |
| 155 | ts | f | g | ts1 | ts | f | g | 'a' | |
| 156 | ============================================================================================================================================ |
| 157 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 158 | __today__ 00:00:01.000 | 102 | 1012 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 159 | __tomorrow__ 00:00:00.000 | 103 | 1013 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 160 | __tomorrow__ 00:00:02.000 | 104 | 1014 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 161 | taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; |
| 162 | ts | f | g | |
| 163 | ====================================================== |
| 164 | __today__ 00:00:00.000 | 101 | 1011 | |
| 165 | __today__ 00:00:01.000 | 102 | 1012 | |
| 166 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 167 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 168 | taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on a.ts = b.ts; |
| 169 | ts1 | ts | f | g | 'a' | |
| 170 | ====================================================================================== |
| 171 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 172 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 173 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 174 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 175 | taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; |
| 176 | c | |
| 177 | ====== |
| 178 | a | |
| 179 | a | |
| 180 | a | |
| 181 | a | |
| 182 | taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on a.ts = b.ts; |
| 183 | ts | |
| 184 | ========================== |
| 185 | __today__ 00:00:00.000 | |
| 186 | __today__ 00:00:01.000 | |
| 187 | __tomorrow__ 00:00:00.000 | |
| 188 | __tomorrow__ 00:00:02.000 | |
| 189 | taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 190 | ts | f | g | ts1 | ts | f | g | 'a' | |
| 191 | ============================================================================================================================================ |
| 192 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 193 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | |
| 194 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | |
| 195 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | |
| 196 | taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 197 | ts | f | g | |
| 198 | ====================================================== |
| 199 | __today__ 00:00:00.000 | 101 | 1011 | |
| 200 | __today__ 00:00:01.000 | 102 | 1012 | |
| 201 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 202 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 203 | taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 204 | ts1 | ts | f | g | 'a' | |
| 205 | ====================================================================================== |
| 206 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 207 | NULL | NULL | NULL | NULL | NU. | |
| 208 | NULL | NULL | NULL | NULL | NU. | |
| 209 | NULL | NULL | NULL | NULL | NU. | |
| 210 | taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 211 | c | |
| 212 | ====== |
| 213 | a | |
| 214 | NU. | |
| 215 | NU. | |
| 216 | NU. | |
| 217 | taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 218 | ts | |
| 219 | ========================== |
| 220 | __today__ 00:00:00.000 | |
| 221 | NULL | |
| 222 | NULL | |
| 223 | NULL | |
| 224 | taos> select * from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 225 | ts | f | g | ts1 | ts | f | g | 'a' | |
| 226 | ============================================================================================================================================ |
| 227 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 228 | __today__ 00:00:01.000 | 102 | 1012 | NULL | NULL | NULL | NULL | NU. | |
| 229 | __tomorrow__ 00:00:00.000 | 103 | 1013 | NULL | NULL | NULL | NULL | NU. | |
| 230 | __tomorrow__ 00:00:02.000 | 104 | 1014 | NULL | NULL | NULL | NULL | NU. | |
| 231 | taos> select a.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 232 | ts | f | g | |
| 233 | ====================================================== |
| 234 | __today__ 00:00:00.000 | 101 | 1011 | |
| 235 | __today__ 00:00:01.000 | 102 | 1012 | |
| 236 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 237 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 238 | taos> select b.* from a1 a left join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 239 | ts1 | ts | f | g | 'a' | |
| 240 | ====================================================================================== |
| 241 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 242 | NULL | NULL | NULL | NULL | NU. | |
| 243 | NULL | NULL | NULL | NULL | NU. | |
| 244 | NULL | NULL | NULL | NULL | NU. | |
| 245 | taos> select b.c from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 246 | c | |
| 247 | ====== |
| 248 | a | |
| 249 | NU. | |
| 250 | NU. | |
| 251 | NU. | |
| 252 | taos> select b.ts from a1 a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 253 | ts | |
| 254 | ========================== |
| 255 | __today__ 00:00:00.000 | |
| 256 | NULL | |
| 257 | NULL | |
| 258 | NULL | |
| 259 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 260 | ts | |
| 261 | ========================== |
| 262 | __today__ 00:00:00.000 | |
| 263 | NULL | |
| 264 | NULL | |
| 265 | NULL | |
| 266 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; |
| 267 | ts | |
| 268 | ========================== |
| 269 | __today__ 00:00:00.000 | |
| 270 | __today__ 00:00:01.000 | |
| 271 | __tomorrow__ 00:00:00.000 | |
| 272 | __tomorrow__ 00:00:02.000 | |
| 273 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a left join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; |
| 274 | ts | |
| 275 | ========================== |
| 276 | __today__ 00:00:00.000 | |
| 277 | __today__ 00:00:01.000 | |
| 278 | __tomorrow__ 00:00:00.000 | |
| 279 | __tomorrow__ 00:00:02.000 | |
| 280 | taos> select b.ts from (select today 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; |
| 281 | ts | |
| 282 | ========================== |
| 283 | NULL | |
| 284 | NULL | |
| 285 | NULL | |
| 286 | NULL | |
| 287 | 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 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; |
| 288 | ts | val | tg1 | ts | val | tg1 | |
| 289 | ============================================================================================================ |
| 290 | __tomorrow__ 00:00:03.000 | 204 | 1 | NULL | NULL | NULL | |
| 291 | 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 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; |
| 292 | ts | val | tg2 | ts | val | tg2 | |
| 293 | ============================================================================================================ |
| 294 | __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | |
| 295 | __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | |
| 296 | 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 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 ta.ts, ta.val, tb.val; |
| 297 | ts | val | tg2 | ts | val | tg2 | |
| 298 | ============================================================================================================ |
| 299 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | |
| 300 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | |
| 301 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | |
| 302 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | |
| 303 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | |
| 304 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | |
| 305 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | |
| 306 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | |
| 307 | __today__ 00:00:01.000 | 102 | 1 | NULL | NULL | NULL | |
| 308 | __today__ 00:00:01.000 | 202 | 2 | NULL | NULL | NULL | |
| 309 | __tomorrow__ 00:00:00.000 | 103 | 1 | NULL | NULL | NULL | |
| 310 | __tomorrow__ 00:00:00.000 | 203 | 2 | NULL | NULL | NULL | |
| 311 | __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | |
| 312 | __tomorrow__ 00:00:03.000 | 204 | 2 | NULL | NULL | NULL | |
| 313 | 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 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; |
| 314 | ts | val | tg2 | ts | val | tg2 | |
| 315 | ============================================================================================================ |
| 316 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | |
| 317 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | |
| 318 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | |
| 319 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | |
| 320 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | |
| 321 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | |
| 322 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | |
| 323 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | |
| 324 | 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 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; |
| 325 | 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; |
| 326 | ts | val | tg2 | ts | val | tg2 | |
| 327 | ============================================================================================================ |
| 328 | __tomorrow__ 00:00:02.000 | 104 | 1 | NULL | NULL | NULL | |
| 329 | __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | |
| 330 | taos> select * from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; |
| 331 | ts | f | g | 'a' | ts | f | g | |
| 332 | ================================================================================================================== |
| 333 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 334 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 335 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 336 | __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 337 | taos> select * from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; |
| 338 | ts1 | f | g | 'a' | ts | f | g | |
| 339 | ================================================================================================================== |
| 340 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 341 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 342 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 343 | __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 344 | taos> select a.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; |
| 345 | ts | f | g | |
| 346 | ====================================================== |
| 347 | __today__ 00:00:00.000 | 101 | 1011 | |
| 348 | __today__ 00:00:00.000 | 101 | 1011 | |
| 349 | __today__ 00:00:00.000 | 101 | 1011 | |
| 350 | __today__ 00:00:00.000 | 101 | 1011 | |
| 351 | taos> select b.* from (select today as ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; |
| 352 | ts | f | g | 'a' | |
| 353 | ============================================================ |
| 354 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 355 | __today__ 00:00:00.000 | 302 | 3012 | a | |
| 356 | __today__ 00:00:00.000 | 303 | 3013 | a | |
| 357 | __today__ 00:00:00.000 | 304 | 3014 | a | |
| 358 | taos> select b.* from (select today as ts1, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts1; |
| 359 | ts1 | f | g | 'a' | |
| 360 | ============================================================ |
| 361 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 362 | __today__ 00:00:00.000 | 302 | 3012 | a | |
| 363 | __today__ 00:00:00.000 | 303 | 3013 | a | |
| 364 | __today__ 00:00:00.000 | 304 | 3014 | a | |
| 365 | taos> select b.c from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; |
| 366 | c | |
| 367 | ====== |
| 368 | a | |
| 369 | a | |
| 370 | a | |
| 371 | a | |
| 372 | taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; |
| 373 | ts | |
| 374 | ========================== |
| 375 | __today__ 00:00:00.000 | |
| 376 | __today__ 00:00:00.000 | |
| 377 | __today__ 00:00:00.000 | |
| 378 | __today__ 00:00:00.000 | |
| 379 | taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; |
| 380 | ts1 | ts | f | g | 'a' | ts | f | g | |
| 381 | ============================================================================================================================================ |
| 382 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 383 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 384 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 385 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 386 | taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; |
| 387 | ts | f | g | |
| 388 | ====================================================== |
| 389 | __today__ 00:00:00.000 | 101 | 1011 | |
| 390 | __today__ 00:00:00.000 | 101 | 1011 | |
| 391 | __today__ 00:00:00.000 | 101 | 1011 | |
| 392 | __today__ 00:00:00.000 | 101 | 1011 | |
| 393 | taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts; |
| 394 | ts1 | ts | f | g | 'a' | |
| 395 | ====================================================================================== |
| 396 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 397 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 398 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 399 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 400 | taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; |
| 401 | c | |
| 402 | ====== |
| 403 | a | |
| 404 | a | |
| 405 | a | |
| 406 | a | |
| 407 | taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts; |
| 408 | ts1 | |
| 409 | ========================== |
| 410 | __today__ 00:00:00.000 | |
| 411 | __today__ 00:00:00.000 | |
| 412 | __today__ 00:00:00.000 | |
| 413 | __today__ 00:00:00.000 | |
| 414 | taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; |
| 415 | ts1 | ts | f | g | 'a' | ts | f | g | |
| 416 | ============================================================================================================================================ |
| 417 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 418 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | |
| 419 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 420 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 421 | taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; |
| 422 | ts | f | g | |
| 423 | ====================================================== |
| 424 | __today__ 00:00:00.000 | 101 | 1011 | |
| 425 | __today__ 00:00:01.000 | 102 | 1012 | |
| 426 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 427 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 428 | taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on a.ts = b.ts; |
| 429 | ts1 | ts | f | g | 'a' | |
| 430 | ====================================================================================== |
| 431 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 432 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 433 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 434 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 435 | taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; |
| 436 | c | |
| 437 | ====== |
| 438 | a | |
| 439 | a | |
| 440 | a | |
| 441 | a | |
| 442 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on a.ts = b.ts; |
| 443 | ts | |
| 444 | ========================== |
| 445 | __today__ 00:00:00.000 | |
| 446 | __today__ 00:00:01.000 | |
| 447 | __tomorrow__ 00:00:00.000 | |
| 448 | __tomorrow__ 00:00:02.000 | |
| 449 | taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 450 | ts1 | ts | f | g | 'a' | ts | f | g | |
| 451 | ============================================================================================================================================ |
| 452 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 453 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | |
| 454 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | |
| 455 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | |
| 456 | taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 457 | ts | f | g | |
| 458 | ====================================================== |
| 459 | __today__ 00:00:00.000 | 101 | 1011 | |
| 460 | NULL | NULL | NULL | |
| 461 | NULL | NULL | NULL | |
| 462 | NULL | NULL | NULL | |
| 463 | taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 464 | ts1 | ts | f | g | 'a' | |
| 465 | ====================================================================================== |
| 466 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 467 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 468 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 469 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 470 | taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 471 | c | |
| 472 | ====== |
| 473 | a | |
| 474 | a | |
| 475 | a | |
| 476 | a | |
| 477 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 478 | ts | |
| 479 | ========================== |
| 480 | __today__ 00:00:00.000 | |
| 481 | __today__ 00:00:01.000 | |
| 482 | __tomorrow__ 00:00:00.000 | |
| 483 | __tomorrow__ 00:00:02.000 | |
| 484 | taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 485 | ts1 | ts | f | g | 'a' | ts | f | g | |
| 486 | ============================================================================================================================================ |
| 487 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 488 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | NULL | NULL | NULL | |
| 489 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | NULL | NULL | NULL | |
| 490 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | NULL | NULL | NULL | |
| 491 | taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 492 | ts | f | g | |
| 493 | ====================================================== |
| 494 | __today__ 00:00:00.000 | 101 | 1011 | |
| 495 | NULL | NULL | NULL | |
| 496 | NULL | NULL | NULL | |
| 497 | NULL | NULL | NULL | |
| 498 | taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 499 | ts1 | ts | f | g | 'a' | |
| 500 | ====================================================================================== |
| 501 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 502 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 503 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 504 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 505 | taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 506 | c | |
| 507 | ====== |
| 508 | a | |
| 509 | a | |
| 510 | a | |
| 511 | a | |
| 512 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b left join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 513 | ts | |
| 514 | ========================== |
| 515 | __today__ 00:00:00.000 | |
| 516 | __today__ 00:00:01.000 | |
| 517 | __tomorrow__ 00:00:00.000 | |
| 518 | __tomorrow__ 00:00:02.000 | |
| 519 | taos> select * from (select today 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; |
| 520 | ts | val | tg1 | ts | val | tg1 | |
| 521 | ============================================================================================================ |
| 522 | __today__ 00:00:00.000 | 404 | 1 | NULL | NULL | NULL | |
| 523 | taos> select * from (select today 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; |
| 524 | ts | val | tg2 | ts | val | tg2 | |
| 525 | ============================================================================================================ |
| 526 | __today__ 00:00:00.000 | 304 | 1 | NULL | NULL | NULL | |
| 527 | __today__ 00:00:00.000 | 404 | 2 | NULL | NULL | NULL | |
| 528 | taos> select * from (select today 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;; |
| 529 | ts | val | tg2 | ts | val | tg2 | |
| 530 | ============================================================================================================ |
| 531 | __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 532 | __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 533 | __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 534 | __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 535 | __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 536 | __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 537 | __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 538 | __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 539 | taos> select * from (select today 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=today where tb.ts=today order by tb.val; |
| 540 | ts | val | tg2 | ts | val | tg2 | |
| 541 | ============================================================================================================ |
| 542 | __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 543 | __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 544 | __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 545 | __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 546 | __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 547 | __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 548 | __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 549 | __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 550 | taos> select * from (select today 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>today where tb.ts>today; |