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
42 KiB
42 KiB
| 1 | taos> use test; |
|---|---|
| 2 | Database changed. |
| 3 | taos> select * from a1 a right 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 | taos> select * from a1 a right 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 | |
| 17 | taos> select a.* from a1 a right 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 | |
| 24 | taos> select b.* from a1 a right 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 | |
| 31 | taos> select b.* from a1 a right 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 | |
| 38 | taos> select a.*, b.ts from a1 a right 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 | |
| 45 | taos> select b.c from a1 a right 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 | |
| 52 | taos> select b.ts from a1 a right 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 | |
| 59 | taos> select * from a1 a right 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 | |
| 66 | taos> select a.* from a1 a right 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 | |
| 73 | taos> select b.* from a1 a right 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 | |
| 80 | taos> select b.c from a1 a right 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 | |
| 87 | taos> select * from a1 a right 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 | |
| 94 | taos> select a.* from a1 a right 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 | |
| 101 | taos> select b.* from a1 a right 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 | |
| 108 | taos> select b.ts1,a.ts from a1 a right 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 | |
| 115 | taos> select * from a1 a right 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 | |
| 122 | taos> select a.* from a1 a right 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 | |
| 129 | taos> select b.* from a1 a right 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 | |
| 136 | taos> select b.c from a1 a right 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 | |
| 143 | taos> select b.ts from a1 a right 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 | |
| 150 | taos> select * from a1 a right 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 | |
| 154 | NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 155 | NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 156 | NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 157 | taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 158 | ts | f | g | |
| 159 | ====================================================== |
| 160 | __today__ 00:00:00.000 | 101 | 1011 | |
| 161 | NULL | NULL | NULL | |
| 162 | NULL | NULL | NULL | |
| 163 | NULL | NULL | NULL | |
| 164 | taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 165 | ts1 | ts | f | g | 'a' | |
| 166 | ====================================================================================== |
| 167 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 168 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 169 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 170 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 171 | taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 172 | c | |
| 173 | ====== |
| 174 | a | |
| 175 | a | |
| 176 | a | |
| 177 | a | |
| 178 | taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts and a.ts = b.ts; |
| 179 | ts | |
| 180 | ========================== |
| 181 | __today__ 00:00:00.000 | |
| 182 | __today__ 00:00:01.000 | |
| 183 | __tomorrow__ 00:00:00.000 | |
| 184 | __tomorrow__ 00:00:02.000 | |
| 185 | taos> select * from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 186 | ts | f | g | ts1 | ts | f | g | 'a' | |
| 187 | ============================================================================================================================================ |
| 188 | __today__ 00:00:00.000 | 101 | 1011 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 189 | NULL | NULL | NULL | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 190 | NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 191 | NULL | NULL | NULL | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 192 | taos> select a.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 193 | ts | f | g | |
| 194 | ====================================================== |
| 195 | __today__ 00:00:00.000 | 101 | 1011 | |
| 196 | NULL | NULL | NULL | |
| 197 | NULL | NULL | NULL | |
| 198 | NULL | NULL | NULL | |
| 199 | taos> select b.* from a1 a right join (select today as ts1, ts, f, g, 'a' from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 200 | ts1 | ts | f | g | 'a' | |
| 201 | ====================================================================================== |
| 202 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 203 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 204 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 205 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 206 | taos> select b.c from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 207 | c | |
| 208 | ====== |
| 209 | a | |
| 210 | a | |
| 211 | a | |
| 212 | a | |
| 213 | taos> select b.ts from a1 a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 214 | ts | |
| 215 | ========================== |
| 216 | __today__ 00:00:00.000 | |
| 217 | __today__ 00:00:01.000 | |
| 218 | __tomorrow__ 00:00:00.000 | |
| 219 | __tomorrow__ 00:00:02.000 | |
| 220 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 221 | ts | |
| 222 | ========================== |
| 223 | __today__ 00:00:00.000 | |
| 224 | __today__ 00:00:01.000 | |
| 225 | __tomorrow__ 00:00:00.000 | |
| 226 | __tomorrow__ 00:00:02.000 | |
| 227 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; |
| 228 | ts | |
| 229 | ========================== |
| 230 | __today__ 00:00:00.000 | |
| 231 | __today__ 00:00:01.000 | |
| 232 | __tomorrow__ 00:00:00.000 | |
| 233 | __tomorrow__ 00:00:02.000 | |
| 234 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1 order by f) a right join (select today as ts1, ts, f, g, 'a' c from b1) b on b.ts1 = a.ts1 and a.ts = b.ts; |
| 235 | ts | |
| 236 | ========================== |
| 237 | __today__ 00:00:00.000 | |
| 238 | __today__ 00:00:01.000 | |
| 239 | __tomorrow__ 00:00:00.000 | |
| 240 | __tomorrow__ 00:00:02.000 | |
| 241 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from a1) a right join (select now() as ts1, ts, f, g, 'a' c from b1) b on b.ts = a.ts and a.ts = b.ts1; |
| 242 | ts | |
| 243 | ========================== |
| 244 | __today__ 00:00:00.000 | |
| 245 | __today__ 00:00:01.000 | |
| 246 | __tomorrow__ 00:00:00.000 | |
| 247 | __tomorrow__ 00:00:02.000 | |
| 248 | 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 right 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; |
| 249 | ts | val | tg1 | ts | val | tg1 | |
| 250 | ============================================================================================================ |
| 251 | NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 1 | |
| 252 | 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 right 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; |
| 253 | ts | val | tg2 | ts | val | tg2 | |
| 254 | ============================================================================================================ |
| 255 | NULL | NULL | NULL | __today__ 00:00:00.000 | 304 | 1 | |
| 256 | NULL | NULL | NULL | __today__ 00:00:00.000 | 404 | 2 | |
| 257 | 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 right 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; |
| 258 | ts | val | tg2 | ts | val | tg2 | |
| 259 | ============================================================================================================ |
| 260 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | |
| 261 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | |
| 262 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | |
| 263 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | |
| 264 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | |
| 265 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | |
| 266 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | |
| 267 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | |
| 268 | 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 right 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; |
| 269 | ts | val | tg2 | ts | val | tg2 | |
| 270 | ============================================================================================================ |
| 271 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 301 | 1 | |
| 272 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 302 | 1 | |
| 273 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 303 | 1 | |
| 274 | __today__ 00:00:00.000 | 101 | 1 | __today__ 00:00:00.000 | 304 | 1 | |
| 275 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 401 | 2 | |
| 276 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 402 | 2 | |
| 277 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 403 | 2 | |
| 278 | __today__ 00:00:00.000 | 201 | 2 | __today__ 00:00:00.000 | 404 | 2 | |
| 279 | 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 right 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; |
| 280 | 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 right 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; |
| 281 | ts | val | tg2 | ts | val | tg2 | |
| 282 | ============================================================================================================ |
| 283 | NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 304 | 1 | |
| 284 | __tomorrow__ 00:00:03.000 | 204 | 2 | __tomorrow__ 00:00:03.000 | 404 | 2 | |
| 285 | taos> select * from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; |
| 286 | ts | f | g | 'a' | ts | f | g | |
| 287 | ================================================================================================================== |
| 288 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 289 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 290 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 291 | __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 292 | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | |
| 293 | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 294 | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 295 | taos> select * from (select today as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; |
| 296 | ts1 | f | g | 'a' | ts | f | g | |
| 297 | ================================================================================================================== |
| 298 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 299 | __today__ 00:00:00.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 300 | __today__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 301 | __today__ 00:00:00.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 302 | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | |
| 303 | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 304 | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 305 | taos> select a.* from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; |
| 306 | ts | f | g | |
| 307 | ====================================================== |
| 308 | __today__ 00:00:00.000 | 101 | 1011 | |
| 309 | __today__ 00:00:00.000 | 101 | 1011 | |
| 310 | __today__ 00:00:00.000 | 101 | 1011 | |
| 311 | __today__ 00:00:00.000 | 101 | 1011 | |
| 312 | __today__ 00:00:01.000 | 102 | 1012 | |
| 313 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 314 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 315 | taos> select b.* from (select today as ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; |
| 316 | ts | f | g | 'a' | |
| 317 | ============================================================ |
| 318 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 319 | __today__ 00:00:00.000 | 302 | 3012 | a | |
| 320 | __today__ 00:00:00.000 | 303 | 3013 | a | |
| 321 | __today__ 00:00:00.000 | 304 | 3014 | a | |
| 322 | NULL | NULL | NULL | NU. | |
| 323 | NULL | NULL | NULL | NU. | |
| 324 | NULL | NULL | NULL | NU. | |
| 325 | taos> select b.* from (select today as ts1, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts1; |
| 326 | ts1 | f | g | 'a' | |
| 327 | ============================================================ |
| 328 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 329 | __today__ 00:00:00.000 | 302 | 3012 | a | |
| 330 | __today__ 00:00:00.000 | 303 | 3013 | a | |
| 331 | __today__ 00:00:00.000 | 304 | 3014 | a | |
| 332 | NULL | NULL | NULL | NU. | |
| 333 | NULL | NULL | NULL | NU. | |
| 334 | NULL | NULL | NULL | NU. | |
| 335 | taos> select b.c from (select today as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; |
| 336 | c | |
| 337 | ====== |
| 338 | a | |
| 339 | a | |
| 340 | a | |
| 341 | a | |
| 342 | NU. | |
| 343 | NU. | |
| 344 | NU. | |
| 345 | taos> select b.ts from (select today as ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; |
| 346 | ts | |
| 347 | ========================== |
| 348 | __today__ 00:00:00.000 | |
| 349 | __today__ 00:00:00.000 | |
| 350 | __today__ 00:00:00.000 | |
| 351 | __today__ 00:00:00.000 | |
| 352 | NULL | |
| 353 | NULL | |
| 354 | NULL | |
| 355 | taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; |
| 356 | ts1 | ts | f | g | 'a' | ts | f | g | |
| 357 | ============================================================================================================================================ |
| 358 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 359 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 360 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 361 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 362 | NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | |
| 363 | NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 364 | NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 365 | taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; |
| 366 | ts | f | g | |
| 367 | ====================================================== |
| 368 | __today__ 00:00:00.000 | 101 | 1011 | |
| 369 | __today__ 00:00:00.000 | 101 | 1011 | |
| 370 | __today__ 00:00:00.000 | 101 | 1011 | |
| 371 | __today__ 00:00:00.000 | 101 | 1011 | |
| 372 | __today__ 00:00:01.000 | 102 | 1012 | |
| 373 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 374 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 375 | taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts; |
| 376 | ts1 | ts | f | g | 'a' | |
| 377 | ====================================================================================== |
| 378 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 379 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 380 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 381 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 382 | NULL | NULL | NULL | NULL | NU. | |
| 383 | NULL | NULL | NULL | NULL | NU. | |
| 384 | NULL | NULL | NULL | NULL | NU. | |
| 385 | taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; |
| 386 | c | |
| 387 | ====== |
| 388 | a | |
| 389 | a | |
| 390 | a | |
| 391 | a | |
| 392 | NU. | |
| 393 | NU. | |
| 394 | NU. | |
| 395 | taos> select b.ts1 from (select today as ts1, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts; |
| 396 | ts1 | |
| 397 | ========================== |
| 398 | __today__ 00:00:00.000 | |
| 399 | __today__ 00:00:00.000 | |
| 400 | __today__ 00:00:00.000 | |
| 401 | __today__ 00:00:00.000 | |
| 402 | NULL | |
| 403 | NULL | |
| 404 | NULL | |
| 405 | taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; |
| 406 | ts1 | ts | f | g | 'a' | ts | f | g | |
| 407 | ============================================================================================================================================ |
| 408 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 409 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | __today__ 00:00:01.000 | 102 | 1012 | |
| 410 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 411 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 412 | taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; |
| 413 | ts | f | g | |
| 414 | ====================================================== |
| 415 | __today__ 00:00:00.000 | 101 | 1011 | |
| 416 | __today__ 00:00:01.000 | 102 | 1012 | |
| 417 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 418 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 419 | taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on a.ts = b.ts; |
| 420 | ts1 | ts | f | g | 'a' | |
| 421 | ====================================================================================== |
| 422 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 423 | __today__ 00:00:00.000 | __today__ 00:00:01.000 | 302 | 3012 | a | |
| 424 | __today__ 00:00:00.000 | __tomorrow__ 00:00:00.000 | 303 | 3013 | a | |
| 425 | __today__ 00:00:00.000 | __tomorrow__ 00:00:02.000 | 304 | 3014 | a | |
| 426 | taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; |
| 427 | c | |
| 428 | ====== |
| 429 | a | |
| 430 | a | |
| 431 | a | |
| 432 | a | |
| 433 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on a.ts = b.ts; |
| 434 | ts | |
| 435 | ========================== |
| 436 | __today__ 00:00:00.000 | |
| 437 | __today__ 00:00:01.000 | |
| 438 | __tomorrow__ 00:00:00.000 | |
| 439 | __tomorrow__ 00:00:02.000 | |
| 440 | taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 441 | ts1 | ts | f | g | 'a' | ts | f | g | |
| 442 | ============================================================================================================================================ |
| 443 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 444 | NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | |
| 445 | NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 446 | NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 447 | taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 448 | ts | f | g | |
| 449 | ====================================================== |
| 450 | __today__ 00:00:00.000 | 101 | 1011 | |
| 451 | __today__ 00:00:01.000 | 102 | 1012 | |
| 452 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 453 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 454 | taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 455 | ts1 | ts | f | g | 'a' | |
| 456 | ====================================================================================== |
| 457 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 458 | NULL | NULL | NULL | NULL | NU. | |
| 459 | NULL | NULL | NULL | NULL | NU. | |
| 460 | NULL | NULL | NULL | NULL | NU. | |
| 461 | taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 462 | c | |
| 463 | ====== |
| 464 | a | |
| 465 | NU. | |
| 466 | NU. | |
| 467 | NU. | |
| 468 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts1 = a.ts and a.ts = b.ts; |
| 469 | ts | |
| 470 | ========================== |
| 471 | __today__ 00:00:00.000 | |
| 472 | NULL | |
| 473 | NULL | |
| 474 | NULL | |
| 475 | taos> select * from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 476 | ts1 | ts | f | g | 'a' | ts | f | g | |
| 477 | ============================================================================================================================================ |
| 478 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | __today__ 00:00:00.000 | 101 | 1011 | |
| 479 | NULL | NULL | NULL | NULL | NU. | __today__ 00:00:01.000 | 102 | 1012 | |
| 480 | NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 481 | NULL | NULL | NULL | NULL | NU. | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 482 | taos> select a.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 483 | ts | f | g | |
| 484 | ====================================================== |
| 485 | __today__ 00:00:00.000 | 101 | 1011 | |
| 486 | __today__ 00:00:01.000 | 102 | 1012 | |
| 487 | __tomorrow__ 00:00:00.000 | 103 | 1013 | |
| 488 | __tomorrow__ 00:00:02.000 | 104 | 1014 | |
| 489 | taos> select b.* from (select today as ts1, ts, f, g, 'a' from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 490 | ts1 | ts | f | g | 'a' | |
| 491 | ====================================================================================== |
| 492 | __today__ 00:00:00.000 | __today__ 00:00:00.000 | 301 | 3011 | a | |
| 493 | NULL | NULL | NULL | NULL | NU. | |
| 494 | NULL | NULL | NULL | NULL | NU. | |
| 495 | NULL | NULL | NULL | NULL | NU. | |
| 496 | taos> select b.c from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 497 | c | |
| 498 | ====== |
| 499 | a | |
| 500 | NU. | |
| 501 | NU. | |
| 502 | NU. | |
| 503 | taos> select b.ts from (select today as ts1, ts, f, g, 'a' c from b1) b right join a1 a on b.ts = a.ts and a.ts = b.ts1; |
| 504 | ts | |
| 505 | ========================== |
| 506 | __today__ 00:00:00.000 | |
| 507 | NULL | |
| 508 | NULL | |
| 509 | NULL | |
| 510 | taos> select * from (select today ts, last(f) val, tg1 from stb where tg1 >= 0 partition by tg1 order by ts) tb right 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; |
| 511 | ts | val | tg1 | ts | val | tg1 | |
| 512 | ============================================================================================================ |
| 513 | NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 1 | |
| 514 | taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 order by ts) tb right 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; |
| 515 | ts | val | tg2 | ts | val | tg2 | |
| 516 | ============================================================================================================ |
| 517 | NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | |
| 518 | NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | |
| 519 | taos> select * from (select today ts, last(f) val, tg2 from stb where tg2 >= 0 partition by tg2 interval(1s) order by ts) tb right 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 ta.val, tb.val; |
| 520 | ts | val | tg2 | ts | val | tg2 | |
| 521 | ============================================================================================================ |
| 522 | __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 523 | __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 524 | __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 525 | __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 526 | NULL | NULL | NULL | __today__ 00:00:01.000 | 102 | 1 | |
| 527 | NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 103 | 1 | |
| 528 | NULL | NULL | NULL | __tomorrow__ 00:00:02.000 | 104 | 1 | |
| 529 | __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 530 | __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 531 | __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 532 | __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 533 | NULL | NULL | NULL | __today__ 00:00:01.000 | 202 | 2 | |
| 534 | NULL | NULL | NULL | __tomorrow__ 00:00:00.000 | 203 | 2 | |
| 535 | NULL | NULL | NULL | __tomorrow__ 00:00:03.000 | 204 | 2 | |
| 536 | 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 right 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; |
| 537 | ts | val | tg2 | ts | val | tg2 | |
| 538 | ============================================================================================================ |
| 539 | __today__ 00:00:00.000 | 301 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 540 | __today__ 00:00:00.000 | 302 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 541 | __today__ 00:00:00.000 | 303 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 542 | __today__ 00:00:00.000 | 304 | 1 | __today__ 00:00:00.000 | 101 | 1 | |
| 543 | __today__ 00:00:00.000 | 401 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 544 | __today__ 00:00:00.000 | 402 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 545 | __today__ 00:00:00.000 | 403 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 546 | __today__ 00:00:00.000 | 404 | 2 | __today__ 00:00:00.000 | 201 | 2 | |
| 547 | 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 right 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; |