When aggregating by week, the calculation doesn't start from the first day(Monday) of the week
Bug Description 使用Interval 按周聚合查询时,返回的数据结果集中,每一周开始时间是周四,而非周一。
To Reproduce 测试数据如下: create table data(ts timestamp, value int) insert into data values ("2020-10-01 08:00:01.000 +08", 10) ("2020-10-02 08:00:01.000 +08", 10) ("2020-10-03 08:00:01.000 +08", 10) ("2020-10-04 08:00:01.000 +08", 10) ("2020-10-05 08:00:01.000 +08", 10) ("2020-10-06 08:00:01.000 +08", 10) ("2020-10-07 08:00:01.000 +08", 10) ("2020-10-08 08:00:01.000 +08", 10) ("2020-10-09 08:00:01.000 +08", 10) ("2020-10-10 08:00:01.000 +08", 10) ("2020-10-11 08:00:01.000 +08", 10) ("2020-10-12 08:00:01.000 +08", 10) ("2020-10-13 08:00:01.000 +08", 10) ("2020-10-14 08:00:01.000 +08", 10) ("2020-10-15 08:00:01.000 +08", 10) ("2020-10-16 08:00:01.000 +08", 10) ("2020-10-17 08:00:01.000 +08", 10) ("2020-10-18 08:00:01.000 +08", 10) ("2020-10-19 08:00:01.000 +08", 10) ("2020-10-20 08:00:01.000 +08", 10) ("2020-10-21 08:00:01.000 +08", 10) ("2020-10-22 08:00:01.000 +08", 10) ("2020-10-23 08:00:01.000 +08", 10)
执行查询: SELECT sum(value) as value FROM data WHERE ts> "2020-01-01 08:00:01.000" AND ts<"2021-10-31 00:00:00" INTERVAL(1w) FILL (VALUE, 0)
查询结果:

从下图中可以看到,2020-10-01是星期四。

we will check on that ,pls wait .
thank u
How is going of the issue?
Currently. we don't support cutting date with natural week ,but support the month and year .
it is in our future plan
Another question: 还是上面的测试数据,当interval = 3d的时候, 结果是从 “2020-10-02 00:00:00.000”开始的
taos> select sum(t2) from t2 where ts > '2020-10-01 08:00:01.000 +08' interval(3d);
ts | sum(t2) |
==================================================
2020-10-02 00:00:00.000 | 30 |
2020-10-05 00:00:00.000 | 30 |
2020-10-08 00:00:00.000 | 30 |
2020-10-11 00:00:00.000 | 30 |
2020-10-14 00:00:00.000 | 30 |
2020-10-17 00:00:00.000 | 30 |
2020-10-20 00:00:00.000 | 30 |
2020-10-23 00:00:00.000 | 20 |
Query OK, 8 row(s) in set (0.002670s)
当interval=5d时, 结果是从 “2020-09-30 00:00:00.000”开始的
taos> select sum(value) from data where ts > '2020-10-01 08:00:01.000 +08' interval(5d) ;
ts | sum(value) |
==================================================
2020-09-30 00:00:00.000 | 30 |
2020-10-05 00:00:00.000 | 50 |
2020-10-10 00:00:00.000 | 50 |
2020-10-15 00:00:00.000 | 50 |
2020-10-20 00:00:00.000 | 40 |
Query OK, 5 row(s) in set (0.001613s)
当interval=2d时, 结果是从 “2020-10-01 00:00:00.000”开始的
taos> select sum(value) from data where ts > '2020-10-01 08:00:01.000 +08' interval(2d) ;
ts | sum(value) |
==================================================
2020-10-01 00:00:00.000 | 10 |
2020-10-03 00:00:00.000 | 20 |
2020-10-05 00:00:00.000 | 20 |
2020-10-07 00:00:00.000 | 20 |
2020-10-09 00:00:00.000 | 20 |
2020-10-11 00:00:00.000 | 20 |
2020-10-13 00:00:00.000 | 20 |
2020-10-15 00:00:00.000 | 20 |
2020-10-17 00:00:00.000 | 20 |
2020-10-19 00:00:00.000 | 20 |
2020-10-21 00:00:00.000 | 20 |
2020-10-23 00:00:00.000 | 10 |
Query OK, 12 row(s) in set (0.002054s)
请问这interval 具体是怎么计算的呀?
我们当前不支持自然周,只支持自然月,自然年,自然日。
请问这个解决了吗