I have an interesting problem where I need to round the result of the AVG () function in a certain way for use in the ORDER BY clause.
They are intended for use in recipe ratings.
Examples of rounding formulas:
1.2 -> 1 1.4 -> 1 1.5 -> 1.5 1.6 -> 2 1.9 - >2
I am asking for a list of recipes, and they had to be ordered so that a recipe with one 5-star rating was not ordered above a recipe with 100 ratings, which average 4.9. The second part of the order by points is the calculation of ratings.
If this requires a custom function, I'm not quite sure how to do this.
source share