avg returns average value of expr. You can use it as an aggregate or analytic function.

If you specify distinct, then you can specify only the query_partition_clause of the analytic_clause. The order_by_clause and windowing_clause are not allowed.