v.20.1New Feature

Added avgWeighted Function for Weighted Average Calculation

Added new aggregate function avgWeighted which allows to calculate weighted average. #7898 (Andrey Bodrov)
Added a new aggregate function avgWeighted that calculates the weighted average of values.

Why it matters

The avgWeighted function addresses the need to compute an average where each value contributes proportionally to its assigned weight, providing more accurate aggregated results in scenarios where some data points are more significant than others.

How to use it

Use the avgWeighted aggregate function in your SQL queries by passing two arguments: the value and its corresponding weight. For example:

SELECT avgWeighted(value, weight) FROM table