英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论