The within group statement and group by are not related by half a cent. They are only auxiliary keywords of some single valued aggregate functions. Take the rank function as an example.
Rank is divided into aggregate function and analysis function in Oracle. This paper does not introduce analysis function, but refers to analysis function.
The rank syntax of aggregate function is: rank (expr1, expr2) within group (order by expr3, expr4 [desc/ASC] nulls [first/last])
it means to calculate the sort number of records with expr3 = expr1 and expr4 = expr2 in the result set with expr3 and expr4 as sort conditions, and return it as numeric type. The sorting is non compact, that is, if the first two records are the same, then the sorting number is 1, 1, 3… When using, it is not necessary to match with group by.
As long as you know the meaning of within group in the rank, you can’t learn to use it with other functions.
The functions that can use the within group keyword are rank and deny_ rank,PERCENT_ RANK,PERCENTILE_ CONT,PERCENTILE_ Disc, etc