Answer the question
In order to leave comments, you need to log in
What is the difference between ORDER BY and WITHIN GROUP (ORDER BY) in plain language?
I read the documentation about aggregation expression.
aggregation_function(expression, ORDER BY a) - first sorts the table by a, then applies aggregation_function to the resulting list.
What does aggregation_function(expression), WITHIN GROUP (ORDER BY a) do? I read this part of the documentation many times, the explanations are not clear for a beginner.
Answer the question
In order to leave comments, you need to log in
aggregation_function(expression, ORDER BY a) - first sorts the table by a, then applies the aggregation_function to the resulting list.
What does aggregation_function(expression), WITHIN GROUP (ORDER BY a) do?
SELECT percentile_disc (0.2) WITHIN GROUP (ORDER BY ...)
). SELECT rank() OVER (ORDER BY value) ...; -- вернет ранк данной записи в отсортированном по value списке
SELECT rank(55) WITHIN GROUP (ORDER BY value) ...; -- вернет ранк числа 55, как если бы оно было в отсортированном по value списке
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question