0

我使用 QuestDB 并从 ILP 消息中填充数据。当标签匹配时,我想查看来自同一行不同传感器的数据。例如我先发送

sensors,location=ny temperature=22 1465839830100400200

sensors然后使用符号列location和 double自动创建表temperature。一段时间后,我可以收到另一条消息,例如

sensors,location=ny humidity=35.2 1465839830100400200

如果我什么都不做,humidity字段就会被忽略。如果我手动将湿度字段添加到表中

alter table sensors add column humidity double

在发送第二条消息之前,我仍然返回 2 行,其中一行有温度和空湿度,另一行有湿度和空温度

| timestamp  | location | temperature | humidty |
| ---------- | -------- | ----------- | ------- |
| 2016-06-13 | ny       |        22.0 |         |
| 2016-06-13 | ny       |             |    35.2 |

即使单独发送,如何使温度和湿度达到同一行?

4

1 回答 1

0

这可能不是最高效的,但它很容易:

SELECT timestamp, location, max(temperature), max(humidity) from sensors;
于 2021-10-13T01:31:06.917 回答