如何在Apache IoTDB中查询数据的平均值并将其四舍五入到两位小数点?

huangapple go评论78阅读模式
英文:

How to query average value of data and round it to be two decimal points in Apache IoTDB?

问题

我正在学习Apache IoTDB支持的UDF计算函数,并且我意识到在使用“avg”查询平均值时,似乎会查询整个平均值。我想知道是否可以使用IoTDB中的其他UDF函数查询平均值并保留两位小数,例如?

我查看了所有我能找到的UDF函数的官方手册,但似乎没有一个函数既可以计算平均值,又可以直接返回结果的两位小数。希望有人可以告诉我最新的更新。

英文:

I am learning the UDF calculation functions supported in Apache IoTDB, and I realized that when querying average values using "avg", seems like the whole average value will be queried out. I wonder can the average value be queried out, and to keep, for example, two decimal places using other UDF function in IoTDB?

I checked the official manual for all UDF functions I can found, but seems like there is no function that can both calculate the average value and to directly came back with two decimal points of the result. Hope anyone can refresh me with the new updates.

答案1

得分: 0

Apache IoTDB的最新主版本已经具备了round函数。在这种情况下,您可以使用select round(avg(s1), 2) from root.db.d1,以便保留平均值的两位小数并直接查询。这个官方发布版本在IoTDB版本1.2中,您可以在GitHub上自行打包并尝试使用这个函数。

英文:

The latest master version of Apache IoTDB already has a round function. In this case, you can use select round(avg(s1), 2) from root.db.d1, so that two decimal places of average values can be kept and directly queried. This official release is in IoTDB Version 1.2, and you can package it yourself in github and try this function.

huangapple
  • 本文由 发表于 2023年7月20日 10:32:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76726317.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定