我正在尝试掌握 Riak TS 中最近添加的组。
我无法找到按分钟对结果进行分组的方法,例如计数。我将在下面展示一个示例。
CREATE TABLE Results
(
result VARCHAR NOT NULL,
time TIMESTAMP NOT NULL,
PRIMARY KEY (
(QUANTUM(time, 1, 'm')),
time
)
)
插入物
INSERT INTO FreightMinuteResult VALUES ('Novo', '2017-12-07 12:03:45Z');
INSERT INTO FreightMinuteResult VALUES ('Novo', '2017-12-07 12:04:45Z');
INSERT INTO FreightMinuteResult VALUES ('Novo', '2017-12-07 12:05:45Z');
INSERT INTO FreightMinuteResult VALUES ('Novo', '2017-12-07 12:05:46Z');
询问
select count(*) from FreightMinuteResult where time > '2017-12-07 12:01:00Z' and time < '2017-12-07 12:06:00Z' group by time;
结果是
+--------+--------------------+
|COUNT(*)| time |
+--------+--------------------+
| 1 |2017-12-07T12:04:45Z|
| 1 |2017-12-07T12:03:45Z|
| 1 |2017-12-07T12:05:45Z|
| 1 |2017-12-07T12:05:46Z|
+--------+--------------------+
如何使用 Riak TS 计算每分钟出现的次数?
谢谢。